aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wpt/web-platform-tests/mathml/support/attribute-values.js
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-08-03 11:04:08 -0400
committerGitHub <noreply@github.com>2019-08-03 11:04:08 -0400
commitd2856ce8aeca11e543bc4d9f869400d73451374e (patch)
treeda3408a7a8e2a1127b568a5b6ea98157632f3e9f /tests/wpt/web-platform-tests/mathml/support/attribute-values.js
parentecd32570c0d20b1cf9ea1711d2f819725f74ad17 (diff)
parentb68253eac07a8ca2903859b3148ac1c721930cc4 (diff)
downloadservo-d2856ce8aeca11e543bc4d9f869400d73451374e.tar.gz
servo-d2856ce8aeca11e543bc4d9f869400d73451374e.zip
Auto merge of #23911 - servo-wpt-sync:wpt_update_03-08-2019, r=servo-wpt-sync
Sync WPT with upstream (03-08-2019) Automated downstream sync of changes from upstream as of 03-08-2019. [no-wpt-sync]
Diffstat (limited to 'tests/wpt/web-platform-tests/mathml/support/attribute-values.js')
-rw-r--r--tests/wpt/web-platform-tests/mathml/support/attribute-values.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/wpt/web-platform-tests/mathml/support/attribute-values.js b/tests/wpt/web-platform-tests/mathml/support/attribute-values.js
new file mode 100644
index 00000000000..8408124f49a
--- /dev/null
+++ b/tests/wpt/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);
+ });
+ });
+}