Skip to content

Commit 6d687e5

Browse files
authored
Support [LegacyFactoryFunction] (#869)
1 parent a3a5512 commit 6d687e5

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

baselines/dom.generated.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7075,6 +7075,7 @@ interface HTMLImageElement extends HTMLElement {
70757075
* Sets or retrieves whether the image is a server-side image map.
70767076
*/
70777077
isMap: boolean;
7078+
loading: string;
70787079
/**
70797080
* Sets or retrieves a Uniform Resource Identifier (URI) to a long description of the object.
70807081
*/

inputfiles/idl/HTML - Embedded content.widl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface HTMLSourceElement : HTMLElement {
1515
};
1616

1717
[Exposed=Window,
18-
NamedConstructor=Image(optional unsigned long width, optional unsigned long height)]
18+
LegacyFactoryFunction=Image(optional unsigned long width, optional unsigned long height)]
1919
interface HTMLImageElement : HTMLElement {
2020
[HTMLConstructor] constructor();
2121

@@ -34,6 +34,9 @@ interface HTMLImageElement : HTMLElement {
3434
readonly attribute USVString currentSrc;
3535
[CEReactions] attribute DOMString referrerPolicy;
3636
[CEReactions] attribute DOMString decoding;
37+
[CEReactions] attribute DOMString loading;
3738

3839
Promise<void> decode();
40+
41+
// also has obsolete members
3942
};

inputfiles/idl/HTML - Form elements.widl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ interface HTMLOptGroupElement : HTMLElement {
7676
};
7777

7878
[Exposed=Window,
79-
HTMLConstructor,
80-
NamedConstructor=Option(optional DOMString text = "", optional DOMString value, optional boolean defaultSelected = false, optional boolean selected = false)]
79+
LegacyFactoryFunction=Option(optional DOMString text = "", optional DOMString value, optional boolean defaultSelected = false, optional boolean selected = false)]
8180
interface HTMLOptionElement : HTMLElement {
81+
[HTMLConstructor] constructor();
82+
8283
[CEReactions] attribute boolean disabled;
8384
readonly attribute HTMLFormElement? form;
8485
[CEReactions] attribute DOMString label;
@@ -110,7 +111,7 @@ interface HTMLTextAreaElement : HTMLElement {
110111

111112
readonly attribute DOMString type;
112113
[CEReactions] attribute DOMString defaultValue;
113-
attribute [TreatNullAs=EmptyString] DOMString value;
114+
attribute [LegacyNullToEmptyString] DOMString value;
114115
readonly attribute unsigned long textLength;
115116

116117
readonly attribute boolean willValidate;
@@ -201,4 +202,6 @@ interface HTMLLegendElement : HTMLElement {
201202
[HTMLConstructor] constructor();
202203

203204
readonly attribute HTMLFormElement? form;
205+
206+
// also has obsolete members
204207
};

inputfiles/idl/HTML - Media.widl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface HTMLVideoElement : HTMLMediaElement {
1111
};
1212

1313
[Exposed=Window,
14-
NamedConstructor=Audio(optional DOMString src)]
14+
LegacyFactoryFunction=Audio(optional DOMString src)]
1515
interface HTMLAudioElement : HTMLMediaElement {
1616
[HTMLConstructor] constructor();
1717
};
@@ -210,9 +210,10 @@ interface TimeRanges {
210210
double end(unsigned long index);
211211
};
212212

213-
[Exposed=Window,
214-
Constructor(DOMString type, optional TrackEventInit eventInitDict = {})]
213+
[Exposed=Window]
215214
interface TrackEvent : Event {
215+
constructor(DOMString type, optional TrackEventInit eventInitDict = {});
216+
216217
readonly attribute (VideoTrack or AudioTrack or TextTrack)? track;
217218
};
218219

src/widlprocess.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function convertInterfaceCommon(i: webidl2.InterfaceType | webidl2.InterfaceMixi
118118
"anonymous-methods": { method: [] },
119119
properties: { property: {}, namesakes: {} },
120120
constructor: getConstructor(i.members, i.name) || getOldStyleConstructor(i.extAttrs, i.name),
121-
"named-constructor": getNamedConstructor(i.extAttrs, i.name),
121+
"named-constructor": getLegacyFactoryFunction(i.extAttrs, i.name),
122122
exposed: getExtAttrConcatenated(i.extAttrs, "Exposed"),
123123
global: getExtAttrConcatenated(i.extAttrs, "Global"),
124124
"no-interface-object": hasExtAttr(i.extAttrs, "NoInterfaceObject") ? 1 : undefined,
@@ -210,9 +210,9 @@ function getOldStyleConstructor(extAttrs: webidl2.ExtendedAttribute[], parent: s
210210
}
211211
}
212212

213-
function getNamedConstructor(extAttrs: webidl2.ExtendedAttribute[], parent: string): Browser.NamedConstructor | undefined {
213+
function getLegacyFactoryFunction(extAttrs: webidl2.ExtendedAttribute[], parent: string): Browser.NamedConstructor | undefined {
214214
for (const extAttr of extAttrs) {
215-
if (extAttr.name === "NamedConstructor" && extAttr.rhs && typeof extAttr.rhs.value === "string") {
215+
if (extAttr.name === "LegacyFactoryFunction" && extAttr.rhs && typeof extAttr.rhs.value === "string") {
216216
return {
217217
name: extAttr.rhs.value,
218218
signature: [{

0 commit comments

Comments
 (0)