mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-16 11:02:11 +08:00
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
This commit is contained in:
committed by
Masahiro Wakame
parent
94fa3e9080
commit
2864d46664
@@ -36,6 +36,15 @@ window.HTMLImports.whenReady(() => {
|
||||
|
||||
document.querySelectorAll(`link[type=${window.HTMLImports.IMPORT_LINK_TYPE}`);
|
||||
|
||||
/*
|
||||
* Shadow DOM
|
||||
*/
|
||||
|
||||
var shadow = xFoo.createShadowRoot();
|
||||
xFoo.shadowRoot;
|
||||
shadow.innerHTML;
|
||||
shadow.host;
|
||||
|
||||
/*
|
||||
* Web Components
|
||||
*/
|
||||
|
||||
10
webcomponents.js/webcomponents.js.d.ts
vendored
10
webcomponents.js/webcomponents.js.d.ts
vendored
@@ -31,6 +31,11 @@ declare namespace webcomponents {
|
||||
whenReady(callback: () => void): void;
|
||||
}
|
||||
|
||||
export interface ShadowRootPolyfill extends DocumentFragment {
|
||||
innerHTML: string;
|
||||
host: Element;
|
||||
}
|
||||
|
||||
export interface Polyfill {
|
||||
flags: any;
|
||||
}
|
||||
@@ -41,6 +46,11 @@ declare module "webcomponents.js" {
|
||||
export = webcomponents;
|
||||
}
|
||||
|
||||
interface Element {
|
||||
createShadowRoot(): webcomponents.ShadowRootPolyfill;
|
||||
shadowRoot?: webcomponents.ShadowRootPolyfill;
|
||||
}
|
||||
|
||||
interface Document {
|
||||
registerElement(name: string, prototype: webcomponents.CustomElementInit): webcomponents.CustomElementConstructor;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user