Skip to content

Commit

Permalink
address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Elchi3 committed Dec 19, 2023
1 parent 7b540cd commit 29afa8f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 40 deletions.
16 changes: 0 additions & 16 deletions custom/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5188,22 +5188,6 @@ javascript:
return {result: false, message: e.message};
}
svg:
elements:
a:
xlink_actuate: |-
var instance = document.createElementNS('http://www.w3.org/2000/svg', 'a');
instance.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:actuate', 'onRequest');
return !!instance && instance.getAttributeNS('http://www.w3.org/1999/xlink', 'actuate') === 'onRequest';
xlink_show: |-
var instance = document.createElementNS('http://www.w3.org/2000/svg', 'a');
instance.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:show', 'new');
return !!instance && instance.getAttributeNS('http://www.w3.org/1999/xlink', 'show') === 'new';
xlink_title: |-
var instance = document.createElementNS('http://www.w3.org/2000/svg', 'a');
instance.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:show', 'newTitle');
return !!instance && instance.getAttributeNS('http://www.w3.org/1999/xlink', 'show') === 'newTitle';
# Features defined here also need to be in test-builder/webassembly.ts.
webassembly:
# Features defined here also need to be in https://webassembly.github.io/spec/web-api/index.html or custom/idl/webassembly.idl.
Expand Down
43 changes: 19 additions & 24 deletions test-builder/elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,36 +136,31 @@ const build = async (specElements, customElements) => {
return !!instance && '${attrProp}' in instance;
})()`;

// SVG attributes need some tweaks
// Some SVG attribute names are reflected differently in SVGOM
if (category === "svg") {
// Certain SVG attributes are reflected differently in SVGOM
if (attrProp === "in") {
attrCode = attrCode.replace("'in'", "'in1'");
}
if (attrProp === "kernelUnitLength") {
const replacements = {
baseFrequency: "baseFrequencyX",
in: "in1",
kernelUnitLength: "kernelUnitLengthX",
order: "orderX",
radius: "radiusX",
stdDeviation: "stdDeviationX",
};

if (attrProp in replacements) {

Check failure on line 150 in test-builder/elements.ts

View workflow job for this annotation

GitHub Actions / Test (Linux)

'attrProp' is of type 'unknown'.

Check failure on line 150 in test-builder/elements.ts

View workflow job for this annotation

GitHub Actions / Test (Linux)

'attrProp' is of type 'unknown'.
attrCode = attrCode.replace(
"kernelUnitLength",
"kernelUnitLengthX",
`'${attrProp}'`,
`'${replacements[attrProp]}'`,

Check failure on line 153 in test-builder/elements.ts

View workflow job for this annotation

GitHub Actions / Test (Linux)

Type 'unknown' cannot be used as an index type.

Check failure on line 153 in test-builder/elements.ts

View workflow job for this annotation

GitHub Actions / Test (Linux)

Type 'unknown' cannot be used as an index type.
);
}
if (attrProp === "order") {
attrCode = attrCode.replace("order", "orderX");
}
if (attrProp === "stdDeviation") {
attrCode = attrCode.replace("stdDeviation", "stdDeviationX");
}
if (attrProp === "radius") {
attrCode = attrCode.replace("radius", "radiusX");
}
if (attrProp === "baseFrequency") {
attrCode = attrCode.replace("baseFrequency", "baseFrequencyX");
}
// All xlink:href attributes need special handling
if (attrProp === "xlink_href") {

// All xlink attributes need special handling
if (attrProp.startsWith("xlink_")) {

Check failure on line 158 in test-builder/elements.ts

View workflow job for this annotation

GitHub Actions / Test (Linux)

'attrProp' is of type 'unknown'.

Check failure on line 158 in test-builder/elements.ts

View workflow job for this annotation

GitHub Actions / Test (Linux)

'attrProp' is of type 'unknown'.
const xlinkAttr = attrProp.replace("xlink_", "");

Check failure on line 159 in test-builder/elements.ts

View workflow job for this annotation

GitHub Actions / Test (Linux)

'attrProp' is of type 'unknown'.

Check failure on line 159 in test-builder/elements.ts

View workflow job for this annotation

GitHub Actions / Test (Linux)

'attrProp' is of type 'unknown'.
attrCode = `(function() {
var instance = ${defaultConstructCode};
instance.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', 'test');
return !!instance && instance.getAttributeNS('http://www.w3.org/1999/xlink', 'href') === 'test'
instance.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:${xlinkAttr}', 'test');
return !!instance && instance.getAttributeNS('http://www.w3.org/1999/xlink', '${xlinkAttr}') === 'test'
})()`;
}
}
Expand Down

0 comments on commit 29afa8f

Please sign in to comment.