'use strict'; const { INVALID_CONTENT, INVALID_SRC_ATTR, INVALID_WORKER_ATTR } = require('../errors.js'); const { dedent, unescape } = require('../utils.js'); const hasCommentsOnly = text => !text .replace(/\/\*[\s\S]*?\*\//g, '') .replace(/^\s*(?:\/\/|#).*/gm, '') .trim() ; /* c8 ignore start */ // tested via integration module.exports = element => { const { src, worker } = element.attributes; if (worker) { let { value } = worker; // throw on worker values as ambiguous // @see https://github.com/pyscript/polyscript/issues/43 if (value) throw new SyntaxError(INVALID_WORKER_ATTR); value = src?.value; if (!value) { // throw on empty src attributes if (src) throw new SyntaxError(INVALID_SRC_ATTR); if (!element.childElementCount) value = element.textContent; else { const { innerHTML, localName, type } = element; const name = type || localName.replace(/-script$/, ''); value = unescape(innerHTML); console.warn( `Deprecated: use