Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/selectors/attribute-selector-escape.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>Attribute selectors using CSS-escaped spaces</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<script>
"use strict";
function cssOnlyEscapeSpaces(string) {
return string.replace(/ /gi, "\\ ");
}
const original = " ";
const escaped = cssOnlyEscapeSpaces(original + original);
const doc = new DOMParser().parseFromString(
`<div id="div" style="${original + original}">hello</div>`,
"text/html"
);
test(() => {
const div = doc.getElementById("div");
assert_equals(doc.querySelector(`[style=${escaped}]`), div);
});
</script>