Commit 388838e6 authored by Robert Knight's avatar Robert Knight

Change `hypothesis-asset` attribute to `data-hypothesis-asset`

Adding a custom attribute without a `data-` prefix could potentially
cause headaches for publishers running their code through HTML
validation tools.
parent ddfe8eab
......@@ -78,7 +78,7 @@ function init() {
// Remove all the `<link>`, `<script>` and `<style>` elements added to the
// page by the boot script.
const clientAssets = document.querySelectorAll('[hypothesis-asset]');
const clientAssets = document.querySelectorAll('[data-hypothesis-asset]');
clientAssets.forEach(el => el.remove());
});
}
......
......@@ -36,7 +36,7 @@ const commonPolyfills = [
* @param {HTMLElement} el
*/
function tagElement(el) {
el.setAttribute('hypothesis-asset', '');
el.setAttribute('data-hypothesis-asset', '');
}
/**
......
......@@ -69,13 +69,13 @@ describe('bootstrap', function () {
function findAssets(doc_) {
const scripts = Array.from(
doc_.querySelectorAll('script[hypothesis-asset]')
doc_.querySelectorAll('script[data-hypothesis-asset]')
).map(function (el) {
return el.src;
});
const styles = Array.from(
doc_.querySelectorAll('link[rel="stylesheet"][hypothesis-asset]')
doc_.querySelectorAll('link[rel="stylesheet"][data-hypothesis-asset]')
).map(function (el) {
return el.href;
});
......@@ -102,7 +102,7 @@ describe('bootstrap', function () {
'link[type="application/annotator+html"]'
);
assert.ok(sidebarAppLink);
assert.isTrue(sidebarAppLink.hasAttribute('hypothesis-asset'));
assert.isTrue(sidebarAppLink.hasAttribute('data-hypothesis-asset'));
assert.equal(sidebarAppLink.href, 'https://marginal.ly/app.html');
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment