Skip to content

Commit 5fa4988

Browse files
authored
Merge pull request #366 from e111077/master
HTML Elements in addedTypes.json are mapped tagName -> Interface
2 parents 3c23301 + 3f8d242 commit 5fa4988

File tree

4 files changed

+59
-7
lines changed

4 files changed

+59
-7
lines changed

TS.fsx

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,20 @@ module Data =
428428
| name when Seq.contains name iNames -> name
429429
| _ -> raise (Exception("Element conflict occured! Typename: " + tagName))
430430

431-
[ for i in GetNonCallbackInterfacesByFlavor Flavor.All do
432-
yield! [ for e in i.Elements do
433-
yield (e.Name, i.Name) ] ]
431+
let nativeTagNamesToInterface =
432+
[ for i in GetNonCallbackInterfacesByFlavor Flavor.All do
433+
yield! [ for e in i.Elements do
434+
yield (e.Name, i.Name) ] ]
435+
436+
let addedTagNamesToInterface =
437+
[ for i in InputJson.getAddedItems InputJson.ItemKind.Interface Flavor.All
438+
|> Array.filter (fun i -> Seq.length i.TagNames > 0) do
439+
yield! [ for e in i.TagNames do
440+
match i.Name with
441+
| Some name -> yield (e, name)
442+
| _ -> () ] ]
443+
444+
nativeTagNamesToInterface @ addedTagNamesToInterface
434445
|> Seq.groupBy fst
435446
|> Seq.map ((fun (key, group) -> (key, Seq.map snd group)) >> fun (key, group) ->
436447
key,
@@ -448,15 +459,33 @@ module Data =
448459
match i.Extends with
449460
| "Object" -> []
450461
| super -> super :: (getExtendList super)
451-
| _ -> []
462+
| _ ->
463+
match InputJson.getAddedItemByName iName InputJson.ItemKind.Interface iName with
464+
| Some i ->
465+
match i.Extends with
466+
| Some extends ->
467+
match extends with
468+
| "Object" -> []
469+
| super -> super :: (getExtendList super)
470+
| _ -> []
471+
| _ -> []
452472

453473
let getImplementList(iName : string) =
454474
match GetInterfaceByName iName with
455475
| Some i -> List.ofArray i.Implements
456476
| _ -> []
457-
458-
Array.concat [| allWebNonCallbackInterfaces; worker.Interfaces; worker.MixinInterfaces.Interfaces |]
459-
|> Array.map (fun i -> (i.Name, List.concat [ (getExtendList i.Name); (getImplementList i.Name) ]))
477+
478+
let addedINameToIDependList =
479+
InputJson.getAddedItems InputJson.ItemKind.Interface Flavor.All
480+
|> Array.ofSeq
481+
|> Array.filter (fun i -> i.Name.IsSome)
482+
|> Array.map (fun i -> (Option.get i.Name, List.concat [ (getExtendList (Option.get i.Name)); (getImplementList (Option.get i.Name)) ]))
483+
484+
let nativeINameToIDependList =
485+
Array.concat [| allWebNonCallbackInterfaces; worker.Interfaces; worker.MixinInterfaces.Interfaces |]
486+
|> Array.map (fun i -> (i.Name, List.concat [ (getExtendList i.Name); (getImplementList i.Name) ]))
487+
488+
Array.concat [| addedINameToIDependList; nativeINameToIDependList |]
460489
|> Map.ofArray
461490

462491
/// Distinct event type list, used in the "createEvent" function

baselines/dom.generated.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15084,6 +15084,7 @@ interface HTMLElementTagNameMap {
1508415084
"script": HTMLScriptElement;
1508515085
"section": HTMLElement;
1508615086
"select": HTMLSelectElement;
15087+
"slot": HTMLSlotElement;
1508715088
"small": HTMLElement;
1508815089
"source": HTMLSourceElement;
1508915090
"span": HTMLSpanElement;

inputfiles/addedTypes.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,7 @@
15751575
"name": "HTMLSlotElement",
15761576
"extends": "HTMLElement",
15771577
"flavor": "Web",
1578+
"tagNames": [ "slot" ],
15781579
"properties": [
15791580
{
15801581
"name": "name",

inputfiles/sample.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,5 +355,26 @@
355355
"type": "HTMLCollection"
356356
}
357357
]
358+
},
359+
{
360+
"kind": "interface",
361+
"name": "HTMLSlotElement",
362+
"extends": "HTMLElement",
363+
"flavor": "Web",
364+
"tagNames": [ "slot" ],
365+
"properties": [
366+
{
367+
"name": "name",
368+
"type": "string"
369+
}
370+
],
371+
"methods": [
372+
{
373+
"name": "assignedNodes",
374+
"signatures": [
375+
"assignedNodes(options?: AssignedNodesOptions): Node[]"
376+
]
377+
}
378+
]
358379
}
359380
]

0 commit comments

Comments
 (0)