DefinitelyTyped/webcomponents.js/webcomponents.js-tests.ts
Michael Matloob 2864d46664 webcomponents.js: Add typings for Element.createShadowRoot (#10330)
* webcomponents.js: Add typings for Element.createShadowRoot

createShadowRoot is deprecated in the official Shadow DOM spec,
but is the way to attach a shadow root in the current released
version of webcomponents.js.

* webcomponents.js: remove spurious extra line

* webcomponents.js: remove readonly modifier

Not supported until TS2.

* webcomponents.js: add Element.shadowRoot property
2016-07-29 00:31:34 +09:00

53 lines
998 B
TypeScript

/// <reference path="webcomponents.js.d.ts" />
/*
* Custom Elements
*/
var fooProto = Object.create(HTMLElement.prototype, {
createdCallback() {
// `this` should be the created element
this.getElementsByTagName("a");
}
});
var XFoo = document.registerElement("x-foo", {
prototype: fooProto
});
var xFoo = new XFoo();
xFoo.textContent = "";
document.body.appendChild(xFoo);
window.CustomElements.hasNative;
window.CustomElements.flags;
window.CustomElements.ready;
window.CustomElements.useNative;
/*
* HTMLImports
*/
window.HTMLImports.isIE;
window.HTMLImports.rootDocument.querySelectorAll("div");
window.HTMLImports.useNative;
window.HTMLImports.whenReady(() => {
return window.HTMLImports.ready === true;
});
document.querySelectorAll(`link[type=${window.HTMLImports.IMPORT_LINK_TYPE}`);
/*
* Shadow DOM
*/
var shadow = xFoo.createShadowRoot();
xFoo.shadowRoot;
shadow.innerHTML;
shadow.host;
/*
* Web Components
*/
window.WebComponents.flags;