Skip to content

Commit cdeacb1

Browse files
authored
Add tests for SVG global attributes (#1210)
1 parent 85d85a8 commit cdeacb1

File tree

2 files changed

+99
-8
lines changed

2 files changed

+99
-8
lines changed

custom/elements.json

+93
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,99 @@
565565
}
566566
},
567567
"svg": {
568+
"global_attributes": {
569+
"attributes": [
570+
{"class": "className", "tabindex": "tabIndex"},
571+
"clip",
572+
"color",
573+
"cursor",
574+
"data",
575+
"direction",
576+
"display",
577+
"fill",
578+
"filter",
579+
"href",
580+
"id",
581+
"kerning",
582+
"lang",
583+
"mask",
584+
"onabort",
585+
"onactivate",
586+
"onbegin",
587+
"oncancel",
588+
"oncanplay",
589+
"oncanplaythrough",
590+
"onchange",
591+
"onclick",
592+
"onclose",
593+
"oncuechange",
594+
"ondblclick",
595+
"ondrag",
596+
"ondragend",
597+
"ondragenter",
598+
"ondragexit",
599+
"ondragleave",
600+
"ondragover",
601+
"ondragstart",
602+
"ondrop",
603+
"ondurationchange",
604+
"onemptied",
605+
"onend",
606+
"onended",
607+
"onerror",
608+
"onfocus",
609+
"onfocusin",
610+
"onfocusout",
611+
"oninput",
612+
"oninvalid",
613+
"onkeydown",
614+
"onkeypress",
615+
"onkeyup",
616+
"onload",
617+
"onloadeddata",
618+
"onloadedmetadata",
619+
"onloadstart",
620+
"onmousedown",
621+
"onmouseenter",
622+
"onmouseleave",
623+
"onmousemove",
624+
"onmouseout",
625+
"onmouseover",
626+
"onmouseup",
627+
"onmousewheel",
628+
"onpause",
629+
"onplay",
630+
"onplaying",
631+
"onprogress",
632+
"onratechange",
633+
"onrepeat",
634+
"onreset",
635+
"onresize",
636+
"onscroll",
637+
"onseeked",
638+
"onseeking",
639+
"onselect",
640+
"onshow",
641+
"onstalled",
642+
"onsubmit",
643+
"onsuspend",
644+
"ontimeupdate",
645+
"ontoggle",
646+
"onunload",
647+
"onvolumechange",
648+
"onwaiting",
649+
"opacity",
650+
"overflow",
651+
"requiredExtensions",
652+
"requiredFeatures",
653+
"stroke",
654+
"style",
655+
"systemLanguage",
656+
"textLength",
657+
"transform",
658+
"visibility"
659+
]
660+
},
568661
"cursor": {
569662
"interfaceName": "SVGCursorElement",
570663
"attributes": ["href", "x", "xlink_href", "y"]

test-builder/elements.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -131,28 +131,26 @@ const build = async (specElements, customElements) => {
131131
? `${category}.global_attributes`
132132
: `${category}.elements`;
133133

134-
const interfaceName = data.interfaceName || categoryData.default;
135-
if (!interfaceName) {
136-
throw new Error(`${bcdPath} is missing an interface name`);
137-
}
138-
139134
const customTest = await getCustomTest(bcdPath, subcat, true);
140135

141136
const defaultConstructCode = namespace
142137
? `document.createElementNS('${namespace}', '${el}')`
143138
: `document.createElement('${el}')`;
144139

145140
if (el !== "global_attributes") {
141+
const interfaceName = data.interfaceName || categoryData.default;
142+
if (!interfaceName) {
143+
throw new Error(`${bcdPath} is missing an interface name`);
144+
}
145+
146146
const defaultCode =
147147
category === "mathml"
148148
? `(function () {
149149
throw new Error('MathML elements require custom tests');
150150
})()`
151151
: `(function() {
152152
var instance = ${defaultConstructCode};
153-
return bcd.testObjectName(instance, '${
154-
data.interfaceName || categoryData.default
155-
}');
153+
return bcd.testObjectName(instance, '${interfaceName}');
156154
})()`;
157155
tests[bcdPath] = compileTest({
158156
raw: {code: customTest.test || defaultCode},

0 commit comments

Comments
 (0)