Skip to content

Commit 99c5952

Browse files
authored
Iterate inheritance chain when searching for PutForwards (microsoft#2046)
Co-authored-by: saschanaz <[email protected]>
1 parent 60a1cdb commit 99c5952

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

inputfiles/overridingTypes.jsonc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,17 +1080,6 @@
10801080
}
10811081
}
10821082
},
1083-
"Notification": {
1084-
"properties": {
1085-
"property": {
1086-
"maxActions": {
1087-
// BCD incorrectly indicates Firefox support
1088-
// https://bugzilla.mozilla.org/show_bug.cgi?id=1225110#c31
1089-
"exposed": ""
1090-
}
1091-
}
1092-
}
1093-
},
10941083
"IDBObjectStore": {
10951084
"methods": {
10961085
"method": {

src/build/emitter.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,21 @@ export function emitWebIdl(
827827
);
828828
}
829829

830+
function getPropertyFromInterface(
831+
i: Browser.Interface,
832+
propertyName: string,
833+
) {
834+
let property;
835+
let currentInterface: Browser.Interface | undefined = i;
836+
while (!property && currentInterface) {
837+
property = currentInterface.properties?.property[propertyName];
838+
currentInterface = currentInterface.extends
839+
? allInterfacesMap[currentInterface.extends]
840+
: undefined;
841+
}
842+
return property;
843+
}
844+
830845
function emitProperty(
831846
prefix: string,
832847
i: Browser.Interface,
@@ -871,8 +886,10 @@ export function emitWebIdl(
871886
if (!prefix && canPutForward && p.putForwards) {
872887
printer.printLine(`get ${p.name}${optionalModifier}(): ${pType};`);
873888

874-
const forwardingProperty =
875-
allInterfacesMap[pType].properties?.property[p.putForwards];
889+
const forwardingProperty = getPropertyFromInterface(
890+
allInterfacesMap[pType],
891+
p.putForwards,
892+
);
876893
if (!forwardingProperty) {
877894
throw new Error("Couldn't find [PutForwards]");
878895
}

0 commit comments

Comments
 (0)