diff --git a/__tests__/__snapshots__/index.test.ts.snap b/__tests__/__snapshots__/index.test.ts.snap index aafb512b..38aee6f4 100644 --- a/__tests__/__snapshots__/index.test.ts.snap +++ b/__tests__/__snapshots__/index.test.ts.snap @@ -3385,93 +3385,6 @@ console.log(modules_06c16b9a.module, modules_c2f65cd3.composition, modules_b033f " `; -exports[`modules inject-object: js 1`] = ` -"/** @type {HTMLElement[]} */ -var containers = []; -/** @type {{prepend:HTMLStyleElement,append:HTMLStyleElement}[]} */ -var styleTags = []; - -/** - * @param {string} css - * @param {object} [options={}] - * @param {boolean} [options.prepend] - * @param {boolean} [options.singleTag] - * @param {string} [options.container] - * @param {Record} [options.attributes] - * @returns {void} - */ -function injector_86728f90 (css, options) { - if (!css || typeof document === \\"undefined\\") return; - if (typeof options === \\"undefined\\") options = {}; - - var position = options.prepend === true ? \\"prepend\\" : \\"append\\"; - var singleTag = typeof options.singleTag !== \\"undefined\\" ? options.singleTag : false; - - var container = - typeof options.container !== \\"undefined\\" - ? document.querySelector(options.container) - : document.getElementsByTagName(\\"head\\")[0]; - - function createStyleTag() { - var styleTag = document.createElement(\\"style\\"); - styleTag.setAttribute(\\"type\\", \\"text/css\\"); - if (options.attributes) { - var k = Object.keys(options.attributes); - for (var i = 0; i < k.length; i++) { - styleTag.setAttribute(k[i], options.attributes[k[i]]); - } - } - var pos = position === \\"prepend\\" ? \\"afterbegin\\" : \\"beforeend\\"; - container.insertAdjacentElement(pos, styleTag); - return styleTag; - } - - /** @type {HTMLStyleElement} */ - var styleTag; - - if (singleTag) { - var id = containers.indexOf(container); - - if (id === -1) { - id = containers.push(container) - 1; - styleTags[id] = {}; - } - - if (styleTags[id] && styleTags[id][position]) { - styleTag = styleTags[id][position]; - } else { - styleTag = styleTags[id][position] = createStyleTag(); - } - } else { - styleTag = createStyleTag(); - } - - // strip potential UTF-8 BOM if css was read from a file - if (css.charCodeAt(0) === 0xfeff) css = css.substring(1); - - if (styleTag.styleSheet) { - styleTag.styleSheet.cssText += css; - } else { - styleTag.appendChild(document.createTextNode(css)); - } -} - -const css_6856db17 = \\".style_module {\\\\n color: #1F4F7F;\\\\n}\\\\n\\\\n.style_module2 {\\\\n}\\\\n\\"; -const modules_06c16b9a = {\\"primary\\":\\"#BF4040\\",\\"secondary\\":\\"#1F4F7F\\",\\"module\\":\\"style_module\\",\\"module2\\":\\"style_module2 composed_composition composition2_compositioned\\"}; -injector_86728f90(css_6856db17); - -const css_99f8382e = \\"@media screen and (min-width: 900px) {\\\\n .composed_composition {\\\\n background-color: aqua;\\\\n }\\\\n}\\\\n\\\\n.composed_composition {\\\\n background-color: #BF4040;\\\\n}\\\\n\\"; -const modules_c2f65cd3 = {\\"primary\\":\\"#BF4040\\",\\"composition\\":\\"composed_composition composition2_compositioned\\"}; -injector_86728f90(css_99f8382e); - -const css_1f7ddd56 = \\".composition2_compositioned {\\\\n width: 30%;\\\\n}\\\\n\\"; -const modules_b033f21c = {\\"compositioned\\":\\"composition2_compositioned\\"}; -injector_86728f90(css_1f7ddd56); - -console.log(modules_06c16b9a.module, modules_c2f65cd3.composition, modules_b033f21c.compositioned); -" -`; - exports[`modules named-exports: js 1`] = ` "/** @type {HTMLElement[]} */ var containers = []; diff --git a/__tests__/index.test.ts b/__tests__/index.test.ts index 404c4076..66e1a5e1 100644 --- a/__tests__/index.test.ts +++ b/__tests__/index.test.ts @@ -192,17 +192,6 @@ validateMany("modules", [ input: "modules/index.js", options: { modules: true }, }, - { - title: "inject-object", - input: "modules/index.js", - options: { - modules: { - getReplacements: () => { - /* noop */ - }, - }, - }, - }, { title: "generate-scoped-name", input: "modules-duplication/index.js",