diff --git a/application/source/dom/constants.mjs b/application/source/dom/constants.mjs index 1d8a53b902ca40cc55e20a5fa0442b64277d971b..432ae76ebcac8f1363b321b256d159bbab018224 100644 --- a/application/source/dom/constants.mjs +++ b/application/source/dom/constants.mjs @@ -16,7 +16,6 @@ export { ATTRIBUTE_UPDATER_SELECT_THIS, ATTRIBUTE_UPDATER_REPLACE, ATTRIBUTE_UPDATER_INSERT, - ATTRIBUTE_UPDATER_INSERT_TEMPLATE_ID, ATTRIBUTE_UPDATER_INSERT_REFERENCE, ATTRIBUTE_UPDATER_REMOVE, ATTRIBUTE_UPDATER_BIND, @@ -143,14 +142,6 @@ const ATTRIBUTE_UPDATER_REPLACE = `${ATTRIBUTE_PREFIX}replace`; */ const ATTRIBUTE_UPDATER_INSERT = `${ATTRIBUTE_PREFIX}insert`; -/** - * @memberOf Monster.DOM - * @type {string} - * @license AGPLv3 - * @since 3.21.0 - */ -const ATTRIBUTE_UPDATER_INSERT_TEMPLATE_ID = `${ATTRIBUTE_UPDATER_INSERT}-template-id`; - /** * @memberOf Monster.DOM * @type {string} diff --git a/application/source/dom/updater.mjs b/application/source/dom/updater.mjs index 6bb6459f2814cf9e889d3716057ca54f38ab2347..38ffcdd9ada5054db8a72eb5447b4692aab15d17 100644 --- a/application/source/dom/updater.mjs +++ b/application/source/dom/updater.mjs @@ -17,8 +17,7 @@ import { ATTRIBUTE_UPDATER_INSERT_REFERENCE, ATTRIBUTE_UPDATER_REMOVE, ATTRIBUTE_UPDATER_REPLACE, - ATTRIBUTE_UPDATER_SELECT_THIS, - ATTRIBUTE_UPDATER_INSERT_TEMPLATE_ID + ATTRIBUTE_UPDATER_SELECT_THIS } from "../dom/constants.mjs"; import {Base} from "../types/base.mjs"; @@ -514,50 +513,6 @@ function insertElement(change) { } } -/** - * @private - * @param container - * @param key - * @param ref - * @param path - * @returns {any} - */ -function internalTemplateLookUp(container, key, ref, path) { - - let templateID = key; - let template; - - if (container.hasAttribute(ATTRIBUTE_UPDATER_INSERT_TEMPLATE_ID)) { - templateID = container.getAttribute(ATTRIBUTE_UPDATER_INSERT_TEMPLATE_ID); - template = findDocumentTemplate(templateID, container); - if (template instanceof HTMLTemplateElement) { - return template; - } - } - - if (container.closest(`[${ATTRIBUTE_UPDATER_INSERT_TEMPLATE_ID}]`)) { - templateID = container.closest(`[${ATTRIBUTE_UPDATER_INSERT_TEMPLATE_ID}]`).getAttribute(ATTRIBUTE_UPDATER_INSERT_TEMPLATE_ID); - template = findDocumentTemplate(templateID, container); - if (template instanceof HTMLTemplateElement) { - return template; - } - } - - const rootNode = container.getRootNode(); - if (rootNode instanceof ShadowRoot) { - const host = rootNode?.host; - if (host && host.hasAttribute(ATTRIBUTE_UPDATER_INSERT_TEMPLATE_ID)) { - templateID = host.getAttribute(ATTRIBUTE_UPDATER_INSERT_TEMPLATE_ID); - template = findDocumentTemplate(templateID, container); - if (template instanceof HTMLTemplateElement) { - return template; - } - } - } - - return findDocumentTemplate(templateID, container); -} - /** * * @private @@ -570,8 +525,7 @@ function internalTemplateLookUp(container, key, ref, path) { * @throws {Error} no template was found with the specified key. */ function appendNewDocumentFragment(container, key, ref, path) { - - let template = internalTemplateLookUp(container, key, ref, path); + let template = findDocumentTemplate(key, container); let nodes = template.createDocumentFragment(); for (const [, node] of Object.entries(nodes.childNodes)) { diff --git a/development/playground/dom-insert/index.html b/development/playground/dom-insert/index.html index 39665b73d1289a710dc92257d6c1ed7c81728e47..f02d2114608f937fc0b5fd62ca6b8c4db50fd4af 100644 --- a/development/playground/dom-insert/index.html +++ b/development/playground/dom-insert/index.html @@ -3,11 +3,11 @@ <head> <script type="module" src="main.mjs"></script> </head> -<body data-monster-insert-template-id="bla"> +<body> <h1>Updater</h1> -<template id="bla"> +<template id="current"> <li data-monster-replace="path:current | index:j"></li> </template> <div id="test1"> diff --git a/development/playground/vite.config.js b/development/playground/vite.config.js index 97534a42bc35564449e018a53e24c7e3340446c7..c113478d838e9547b3a37d6ef3004dfb4ed5be22 100644 --- a/development/playground/vite.config.js +++ b/development/playground/vite.config.js @@ -46,14 +46,14 @@ function createStyleSheetPlugin() { return { name: 'buildStart', buildStart() { - console.log('buildStart') - - exec('pnpm run -C ' + scriptDir + " build-style", (err, stdout, stderr) => { - if (err) { - //some err occurred - console.error(err) - } - }); + // console.log('buildStart') + // + // exec('pnpm run -C ' + scriptDir + " build-style", (err, stdout, stderr) => { + // if (err) { + // //some err occurred + // console.error(err) + // } + // }); }, async transform(raw, id, options) {