Commit 5890a1be authored by Robert Knight's avatar Robert Knight

Replace `js-temp-config` class with `data-remove-on-unload` attribute

Per discussion in [1], replace the `js-temp-config` marker class with a
more descriptively-named data attribute.

[1] https://github.com/hypothesis/client/pull/5008#discussion_r1029807692
parent 6cf7a391
......@@ -62,7 +62,9 @@ function hasHypothesis(iframe) {
*/
export function removeTemporaryClientConfig(document_ = document) {
const tempConfigEls = Array.from(
document_.querySelectorAll('script.js-temp-config')
document_.querySelectorAll(
'script.js-hypothesis-config[data-remove-on-unload]'
)
);
tempConfigEls.forEach(el => el.remove());
}
......@@ -114,7 +116,8 @@ export async function injectClient(frame, config, frameId) {
};
const configElement = document.createElement('script');
configElement.className = 'js-hypothesis-config js-temp-config';
configElement.className = 'js-hypothesis-config';
configElement.setAttribute('data-remove-on-unload', '');
configElement.type = 'application/json';
configElement.innerText = JSON.stringify(injectedConfig);
......
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