How to use the metal-dom.dom.append function in metal-dom

To help you get started, we’ve selected a few metal-dom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github metal / metal.js / test / Component.js View on Github external
it('should listen to delegate events on the element even before it\'s created', function() {
			comp = new Component({}, false);
			var listener = sinon.stub();
			comp.delegate('click', '.foo', listener);

			var element = document.createElement('div');
			dom.append(element, '<div class="foo"></div>');
			comp.element = element;

			dom.triggerEvent(element.querySelector('.foo'), 'click');
			assert.strictEqual(1, listener.callCount);
		});
github metal / metal.js / test / Component.js View on Github external
it('should not reatach delegate listeners that were detached when element changes', function() {
			var CustomComponent = createCustomComponentClass('<div class="foo"></div>');
			comp = new CustomComponent();

			var listener = sinon.stub();
			var handle = comp.delegate('click', '.foo', listener);
			handle.removeListener();

			var newElement = document.createElement('div');
			comp.element = newElement;
			dom.append(newElement, '<div class="foo"></div>');

			dom.triggerEvent(newElement.querySelector('.foo'), 'click');
			assert.strictEqual(0, listener.callCount);
		});
github metal / metal.js / src / surfaces / SurfaceRenderer.js View on Github external
convertHtmlToBrowserFormat_(htmlString) {
		var element = document.createElement('div');
		dom.append(element, htmlString);
		return element.innerHTML;
	}
github metal / metal.js / src / surfaces / SurfaceRenderer.js View on Github external
if (newElement) {
				this.component_.element = newElement;
				return;
			} else {
				this.component_.element = document.createElement('div');
				element = this.component_.element;
			}
		}

		if (newElement) {
			this.updateElementAttributes_(element, newElement);
			newContent = newElement.childNodes;
		}

		dom.removeChildren(element);
		dom.append(element, newContent);
	}