diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/mathml/support/attribute-values.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/mathml/support/attribute-values.js')
-rw-r--r-- | testing/web-platform/tests/mathml/support/attribute-values.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/testing/web-platform/tests/mathml/support/attribute-values.js b/testing/web-platform/tests/mathml/support/attribute-values.js new file mode 100644 index 0000000000..8408124f49 --- /dev/null +++ b/testing/web-platform/tests/mathml/support/attribute-values.js @@ -0,0 +1,31 @@ +AttributeValueTransforms = { + lowercase: function(value) { return value.toLowerCase(); }, + uppercase: function(value) { return value.toUpperCase(); }, + alternate_case: function(value) { + var transformedValue = ""; + for (var i = 0; i < value.length; i++) { + transformedValue += i % 2 ? + value.charAt(i).toLowerCase() : + value.charAt(i).toUpperCase(); + } + return transformedValue; + }, + // TODO: Should we perform this transform too? + // https://github.com/mathml-refresh/mathml/issues/122 + // add_leading_and_trimming_whitespace: function(value) { + // var space = "\0020\0009\000A\000D"; + // return `${space}${space}${value}${space}${space}`; + // }, +}; + +function TransformAttributeValues(transform, attributeNames) { + if (typeof attributeNames === "string") + attributeNames = [attributeNames]; + attributeNames.forEach(name => { + Array.from(document.querySelectorAll(`[${name}]`)).forEach(element => { + var value = element.getAttribute(name); + var transformedValue = AttributeValueTransforms[transform](value); + element.setAttribute(name, transformedValue); + }); + }); +} |