Skip to content

Commit 0bbdd29

Browse files
committed
Merge remote-tracking branch 'upstream/master' into microsoft-build-dir
2 parents 72b9486 + 3a6fa3b commit 0bbdd29

File tree

7 files changed

+63
-46
lines changed

7 files changed

+63
-46
lines changed

baselines/dom.generated.d.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -4538,7 +4538,8 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad
45384538
/**
45394539
* Contains information about the current URL.
45404540
*/
4541-
location: Location;
4541+
get location(): Location;
4542+
set location(href: string | Location);
45424543
onfullscreenchange: ((this: Document, ev: Event) => any) | null;
45434544
onfullscreenerror: ((this: Document, ev: Event) => any) | null;
45444545
onpointerlockchange: ((this: Document, ev: Event) => any) | null;
@@ -18225,7 +18226,8 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler
1822518226
readonly innerHeight: number;
1822618227
readonly innerWidth: number;
1822718228
readonly length: number;
18228-
location: Location;
18229+
get location(): Location;
18230+
set location(href: string | Location);
1822918231
readonly locationbar: BarProp;
1823018232
readonly menubar: BarProp;
1823118233
readonly msContentScript: ExtensionScriptApis;

package.json

+17-17
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@
1717
},
1818
"dependencies": {
1919
"@mdn/browser-compat-data": "2.0.7",
20-
"@types/jsdom": "^16.2.4",
21-
"@types/node": "^14.6.4",
22-
"@types/node-fetch": "^2.5.7",
23-
"@types/webidl2": "^23.13.2",
24-
"@typescript-eslint/eslint-plugin": "^4.16.1",
25-
"@typescript-eslint/parser": "^4.16.1",
26-
"cpx2": "^2.0.0",
27-
"danger": "^10.5.4",
28-
"eslint": "^7.21.0",
29-
"eslint-config-prettier": "^8.1.0",
30-
"eslint-plugin-prettier": "^3.3.1",
31-
"jsdom": "^16.4.0",
20+
"@types/jsdom": "^16.2.10",
21+
"@types/node": "^15.6.1",
22+
"@types/node-fetch": "^2.5.10",
23+
"@types/webidl2": "^23.13.5",
24+
"@typescript-eslint/eslint-plugin": "^4.25.0",
25+
"@typescript-eslint/parser": "^4.25.0",
26+
"cpx2": "^3.0.0",
27+
"danger": "^10.6.4",
28+
"eslint": "^7.27.0",
29+
"eslint-config-prettier": "^8.3.0",
30+
"eslint-plugin-prettier": "^3.4.0",
31+
"jsdom": "^16.6.0",
3232
"node-fetch": "^2.6.1",
33-
"parse-diff": "^0.7.0",
34-
"prettier": "^2.2.1",
33+
"parse-diff": "^0.8.1",
34+
"prettier": "^2.3.0",
3535
"print-diff": "^1.0.0",
36-
"styleless-innertext": "^1.1.2",
37-
"typescript": "^4.2.3",
38-
"webidl2": "^23.13.0"
36+
"styleless-innertext": "^1.1.3",
37+
"typescript": "^4.3.0-dev.20210327",
38+
"webidl2": "^24.1.1"
3939
}
4040
}

src/build/emitter.ts

+25-8
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,10 @@ export function emitWebIdl(
413413
return type;
414414
}
415415

416-
function convertDomTypeToTsTypeWorker(
417-
obj: Browser.Typed
418-
): { name: string; nullable: boolean } {
416+
function convertDomTypeToTsTypeWorker(obj: Browser.Typed): {
417+
name: string;
418+
nullable: boolean;
419+
} {
419420
let type;
420421
if (typeof obj.type === "string") {
421422
type = {
@@ -882,11 +883,27 @@ export function emitWebIdl(
882883
if (!required && prefix) {
883884
pType += " | undefined";
884885
}
885-
const readOnlyModifier =
886-
p["read-only"] === 1 && prefix === "" ? "readonly " : "";
887-
printer.printLine(
888-
`${prefix}${readOnlyModifier}${p.name}${requiredModifier}: ${pType};`
889-
);
886+
if (!prefix && !p["read-only"] && p["put-forwards"]) {
887+
printer.printLine(`get ${p.name}${requiredModifier}(): ${pType};`);
888+
889+
const forwardingProperty =
890+
allInterfacesMap[pType].properties?.property[p["put-forwards"]];
891+
if (!forwardingProperty) {
892+
throw new Error("Couldn't find [PutForwards]");
893+
}
894+
const setterType = `${convertDomTypeToTsType(
895+
forwardingProperty
896+
)} | ${pType}`;
897+
printer.printLine(
898+
`set ${p.name}${requiredModifier}(${p["put-forwards"]}: ${setterType});`
899+
);
900+
} else {
901+
const readOnlyModifier =
902+
p["read-only"] === 1 && prefix === "" ? "readonly " : "";
903+
printer.printLine(
904+
`${prefix}${readOnlyModifier}${p.name}${requiredModifier}: ${pType};`
905+
);
906+
}
890907
}
891908

892909
if (p.stringifier) {

src/build/expose.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ function deepClone<T>(o: T, custom: (o: any) => any): T {
194194
return o;
195195
}
196196
if (Array.isArray(o)) {
197-
return (o.map((v) => deepClone(v, custom)) as any) as T;
197+
return o.map((v) => deepClone(v, custom)) as any as T;
198198
}
199199
const mapped = custom(o);
200200
if (mapped !== undefined) {

src/build/helpers.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ export function filter<T>(
6565
): T {
6666
if (typeof obj === "object") {
6767
if (Array.isArray(obj)) {
68-
return (mapDefined(obj, (e) =>
68+
return mapDefined(obj, (e) =>
6969
fn(e, undefined) ? filter(e, fn) : undefined
70-
) as any) as T;
70+
) as any as T;
7171
} else {
7272
const result: any = {};
7373
for (const e in obj) {

src/build/widlprocess.ts

+8-10
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@ export function convert(text: string, commentMap: Record<string, string>) {
2929
} else if (rootType.type === "namespace") {
3030
browser.namespaces!.push(convertNamespace(rootType, commentMap));
3131
} else if (rootType.type === "callback interface") {
32-
browser["callback-interfaces"]!.interface[
33-
rootType.name
34-
] = convertInterfaceCommon(rootType, commentMap);
32+
browser["callback-interfaces"]!.interface[rootType.name] =
33+
convertInterfaceCommon(rootType, commentMap);
3534
} else if (rootType.type === "callback") {
36-
browser["callback-functions"]!["callback-function"][
37-
rootType.name
38-
] = convertCallbackFunctions(rootType);
35+
browser["callback-functions"]!["callback-function"][rootType.name] =
36+
convertCallbackFunctions(rootType);
3937
addComments(
4038
browser["callback-functions"]!["callback-function"][rootType.name],
4139
commentMap,
@@ -79,10 +77,9 @@ function getExtAttr(extAttrs: webidl2.ExtendedAttribute[], name: string) {
7977
attr.rhs.type === "string-list" ||
8078
attr.rhs.type === "decimal-list" ||
8179
attr.rhs.type === "integer-list"
82-
? (attr.rhs
83-
.value as webidl2.ExtendedAttributeRightHandSideIdentifier[]).map(
84-
(item) => item.value
85-
)
80+
? (
81+
attr.rhs.value as webidl2.ExtendedAttributeRightHandSideIdentifier[]
82+
).map((item) => item.value)
8683
: [attr.rhs.value];
8784
}
8885

@@ -357,6 +354,7 @@ function convertAttribute(
357354
exposed:
358355
getExtAttrConcatenated(attribute.extAttrs, "Exposed") ||
359356
inheritedExposure,
357+
"put-forwards": getExtAttr(attribute.extAttrs, "PutForwards")[0],
360358
};
361359
}
362360

src/fetch-idl.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ const cssPropSelector = [
2626
].join(",");
2727

2828
async function fetchIDLs(filter: string[]) {
29-
const idlSources = (require("../inputfiles/idlSources.json") as IDLSource[]).filter(
30-
(source) => !filter.length || filter.includes(source.title)
31-
);
29+
const idlSources = (
30+
require("../inputfiles/idlSources.json") as IDLSource[]
31+
).filter((source) => !filter.length || filter.includes(source.title));
3232
await Promise.all(
3333
idlSources.map(async (source) => {
3434
const { idl, comments } = await fetchIDL(source);
@@ -92,9 +92,9 @@ function extractIDL(dom: DocumentFragment) {
9292
}
9393

9494
function extractCSSDefinitions(dom: DocumentFragment) {
95-
const properties = Array.from(
96-
dom.querySelectorAll(cssPropSelector)
97-
).map((element) => element.textContent!.trim());
95+
const properties = Array.from(dom.querySelectorAll(cssPropSelector)).map(
96+
(element) => element.textContent!.trim()
97+
);
9898

9999
if (!properties.length) {
100100
return "";

0 commit comments

Comments
 (0)