Bug 1416999 - Remove document.registerElement

Tag #1375
This commit is contained in:
Matt A. Tobin 2020-04-17 07:07:09 -04:00 committed by Roy Tam
commit cedff6e214
28 changed files with 82 additions and 879 deletions

View file

@ -3,23 +3,26 @@
'use strict';
// -sp-context: content
(function () {
let proto = Object.create(HTMLDivElement.prototype);
proto.template = `<style></style>`;
proto.createdCallback = function() {
let shadow = this.createShadowRoot();
if (this.template) {
let te = document.createElement('template');
te.innerHTML = this.template;
shadow.appendChild(document.importNode(te.content, true));
}
};
class UiComponentTest extends HTMLDivElement {
constructor() {
super();
this.template = `<style></style>`;
}
let UiComponentTest = document.registerElement('ui-component-test', {
prototype: proto,
});
connectedCallback() {
let shadow = this.createShadowRoot();
if (this.template) {
let te = document.createElement('template');
te.innerHTML = this.template;
shadow.appendChild(document.importNode(te.content, true));
}
}
};
let uic = new UiComponentTest();
document.body.appendChild(uic);
customElements.define('ui-component-test', UiComponentTest, { extend: 'div'} );
let uic = new UiComponentTest();
document.body.appendChild(uic);
})();
</script>