Skip to content

Commit 0872515

Browse files
authored
Add Shadow DOM v1 APIs (#151)
* Add Shadow DOM v1 APIs Based on https://www.w3.org/TR/2016/WD-shadow-dom-20160830/ * fixup! Add Shadow DOM v1 APIs
2 parents 5c38707 + b1695f2 commit 0872515

File tree

4 files changed

+189
-2
lines changed

4 files changed

+189
-2
lines changed

baselines/dom.generated.d.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ interface DoubleRange {
7676
}
7777

7878
interface EventInit {
79+
scoped?: boolean;
7980
bubbles?: boolean;
8081
cancelable?: boolean;
8182
}
@@ -2291,7 +2292,7 @@ declare var DeviceRotationRate: {
22912292
new(): DeviceRotationRate;
22922293
}
22932294

2294-
interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEvent, ParentNode {
2295+
interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEvent, ParentNode, DocumentOrShadowRoot {
22952296
/**
22962297
* Sets or gets the URL for the current document.
22972298
*/
@@ -3467,6 +3468,9 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
34673468
readonly scrollWidth: number;
34683469
readonly tagName: string;
34693470
innerHTML: string;
3471+
readonly assignedSlot: HTMLSlotElement | null;
3472+
slot: string;
3473+
readonly shadowRoot: ShadowRoot | null;
34703474
getAttribute(name: string): string | null;
34713475
getAttributeNS(namespaceURI: string, localName: string): string;
34723476
getAttributeNode(name: string): Attr;
@@ -3688,6 +3692,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
36883692
insertAdjacentElement(position: string, insertedElement: Element): Element | null;
36893693
insertAdjacentHTML(where: string, html: string): void;
36903694
insertAdjacentText(where: string, text: string): void;
3695+
attachShadow(shadowRootInitDict: ShadowRootInit): ShadowRoot;
36913696
addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void;
36923697
addEventListener(type: "MSGestureDoubleTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void;
36933698
addEventListener(type: "MSGestureEnd", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void;
@@ -3759,10 +3764,12 @@ interface Event {
37593764
readonly target: EventTarget;
37603765
readonly timeStamp: number;
37613766
readonly type: string;
3767+
readonly scoped: boolean;
37623768
initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void;
37633769
preventDefault(): void;
37643770
stopImmediatePropagation(): void;
37653771
stopPropagation(): void;
3772+
deepPath(): EventTarget[];
37663773
readonly AT_TARGET: number;
37673774
readonly BUBBLING_PHASE: number;
37683775
readonly CAPTURING_PHASE: number;
@@ -11521,6 +11528,7 @@ declare var SubtleCrypto: {
1152111528

1152211529
interface Text extends CharacterData {
1152311530
readonly wholeText: string;
11531+
readonly assignedSlot: HTMLSlotElement | null;
1152411532
splitText(offset: number): Text;
1152511533
}
1152611534

@@ -14247,6 +14255,33 @@ interface ParentNode {
1424714255
readonly childElementCount: number;
1424814256
}
1424914257

14258+
interface DocumentOrShadowRoot {
14259+
readonly activeElement: Element | null;
14260+
readonly stylesheets: StyleSheetList;
14261+
getSelection(): Selection | null;
14262+
elementFromPoint(x: number, y: number): Element | null;
14263+
elementsFromPoint(x: number, y: number): Element[];
14264+
}
14265+
14266+
interface ShadowRoot extends DocumentOrShadowRoot, DocumentFragment {
14267+
readonly host: Element;
14268+
innerHTML: string;
14269+
}
14270+
14271+
interface ShadowRootInit {
14272+
mode: 'open'|'closed';
14273+
delegatesFocus?: boolean;
14274+
}
14275+
14276+
interface HTMLSlotElement extends HTMLElement {
14277+
name: string;
14278+
assignedNodes(options?: AssignedNodesOptions): Node[];
14279+
}
14280+
14281+
interface AssignedNodesOptions {
14282+
flatten?: boolean;
14283+
}
14284+
1425014285
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
1425114286

1425214287
interface ErrorEventHandler {

baselines/webworker.generated.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ interface Algorithm {
88
}
99

1010
interface EventInit {
11+
scoped?: boolean;
1112
bubbles?: boolean;
1213
cancelable?: boolean;
1314
}
@@ -242,10 +243,12 @@ interface Event {
242243
readonly target: EventTarget;
243244
readonly timeStamp: number;
244245
readonly type: string;
246+
readonly scoped: boolean;
245247
initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void;
246248
preventDefault(): void;
247249
stopImmediatePropagation(): void;
248250
stopPropagation(): void;
251+
deepPath(): EventTarget[];
249252
readonly AT_TARGET: number;
250253
readonly BUBBLING_PHASE: number;
251254
readonly CAPTURING_PHASE: number;

inputfiles/addedTypes.json

Lines changed: 145 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@
11551155
"type": "string"
11561156
},
11571157
{
1158-
"kind": "interface",
1158+
"kind": "interface",
11591159
"name": "ParentNode",
11601160
"flavor": "DOM",
11611161
"properties": [
@@ -1220,5 +1220,149 @@
12201220
"interface": "CanvasPattern",
12211221
"name": "setTransform",
12221222
"signatures": ["setTransform(matrix: SVGMatrix): void"]
1223+
},
1224+
{
1225+
"kind": "interface",
1226+
"name": "DocumentOrShadowRoot",
1227+
"flavor": "DOM",
1228+
"methods": [
1229+
{
1230+
"name": "getSelection",
1231+
"signatures": ["getSelection(): Selection | null"]
1232+
},
1233+
{
1234+
"name": "elementFromPoint",
1235+
"signatures": ["elementFromPoint(x: number, y: number): Element | null"]
1236+
},
1237+
{
1238+
"name": "elementsFromPoint",
1239+
"signatures": ["elementsFromPoint(x: number, y: number): Element[]"]
1240+
}
1241+
],
1242+
"properties": [
1243+
{
1244+
"name": "activeElement",
1245+
"type": "Element | null",
1246+
"readonly": true
1247+
},
1248+
{
1249+
"name": "stylesheets",
1250+
"type": "StyleSheetList",
1251+
"readonly": true
1252+
}
1253+
]
1254+
},
1255+
{
1256+
"kind": "interface",
1257+
"name": "ShadowRoot",
1258+
"extends": "DocumentOrShadowRoot, DocumentFragment",
1259+
"flavor": "DOM",
1260+
"properties": [
1261+
{
1262+
"name": "host",
1263+
"type": "Element",
1264+
"readonly": true
1265+
},
1266+
{
1267+
"name": "innerHTML",
1268+
"type": "string"
1269+
}
1270+
]
1271+
},
1272+
{
1273+
"kind": "method",
1274+
"interface": "Element",
1275+
"name": "attachShadow",
1276+
"signatures": ["attachShadow(shadowRootInitDict: ShadowRootInit): ShadowRoot"]
1277+
},
1278+
{
1279+
"kind": "property",
1280+
"interface": "Element",
1281+
"name": "assignedSlot",
1282+
"type": "HTMLSlotElement | null",
1283+
"readonly": true
1284+
},
1285+
{
1286+
"kind": "property",
1287+
"interface": "Element",
1288+
"name": "slot",
1289+
"type": "string"
1290+
},
1291+
{
1292+
"kind": "property",
1293+
"interface": "Element",
1294+
"name": "shadowRoot",
1295+
"type": "ShadowRoot | null",
1296+
"readonly": true
1297+
},
1298+
{
1299+
"kind": "interface",
1300+
"name": "ShadowRootInit",
1301+
"flavor": "DOM",
1302+
"properties": [
1303+
{
1304+
"name": "mode",
1305+
"type": "'open'|'closed'"
1306+
},
1307+
{
1308+
"name": "delegatesFocus?",
1309+
"type": "boolean"
1310+
}
1311+
]
1312+
},
1313+
{
1314+
"kind": "property",
1315+
"interface": "Text",
1316+
"name": "assignedSlot",
1317+
"type": "HTMLSlotElement | null",
1318+
"readonly": true
1319+
},
1320+
{
1321+
"kind": "interface",
1322+
"name": "HTMLSlotElement",
1323+
"extends": "HTMLElement",
1324+
"flavor": "DOM",
1325+
"properties": [
1326+
{
1327+
"name": "name",
1328+
"type": "string"
1329+
}
1330+
],
1331+
"methods": [
1332+
{
1333+
"name": "assignedNodes",
1334+
"signatures": ["assignedNodes(options?: AssignedNodesOptions): Node[]"]
1335+
}
1336+
]
1337+
},
1338+
{
1339+
"kind": "interface",
1340+
"name": "AssignedNodesOptions",
1341+
"flavor": "DOM",
1342+
"properties": [
1343+
{
1344+
"name": "flatten?",
1345+
"type": "boolean"
1346+
}
1347+
]
1348+
},
1349+
{
1350+
"kind": "property",
1351+
"interface": "EventInit",
1352+
"name": "scoped?",
1353+
"type": "boolean"
1354+
},
1355+
{
1356+
"kind": "property",
1357+
"interface": "Event",
1358+
"name": "scoped",
1359+
"type": "boolean",
1360+
"readonly": true
1361+
},
1362+
{
1363+
"kind": "method",
1364+
"interface": "Event",
1365+
"name": "deepPath",
1366+
"signatures": ["deepPath(): EventTarget[]"]
12231367
}
12241368
]

inputfiles/overridingTypes.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,5 +924,10 @@
924924
"interface": "XPathExpression",
925925
"name": "evaluate",
926926
"signatures": ["evaluate(contextNode: Node, type: number, result: XPathResult | null): XPathResult"]
927+
},
928+
{
929+
"kind": "extends",
930+
"baseInterface": "Node, GlobalEventHandlers, NodeSelector, DocumentEvent, ParentNode, DocumentOrShadowRoot",
931+
"interface": "Document"
927932
}
928933
]

0 commit comments

Comments
 (0)