diff --git a/.changeset/rich-teams-melt.md b/.changeset/rich-teams-melt.md new file mode 100644 index 0000000000..3b1d640a00 --- /dev/null +++ b/.changeset/rich-teams-melt.md @@ -0,0 +1,5 @@ +--- +"@lynx-js/web-elements": patch +--- + +fix: x-markdown inline view injection no longer queries light DOM children when the content attribute changes. Consumers must now pre-set `slot="{id}"` on the child element they want to project into `inlineview://{id}`. diff --git a/packages/web-platform/web-elements/src/elements/XMarkdown/XMarkdownAttributes.ts b/packages/web-platform/web-elements/src/elements/XMarkdown/XMarkdownAttributes.ts index c9a6b6e444..c14f3c69a2 100644 --- a/packages/web-platform/web-elements/src/elements/XMarkdown/XMarkdownAttributes.ts +++ b/packages/web-platform/web-elements/src/elements/XMarkdown/XMarkdownAttributes.ts @@ -1285,23 +1285,12 @@ export class XMarkdownAttributes { const inlineId = img.getAttribute('data-inlineview'); if (inlineId) { const id = inlineId; - const view = this.#dom.querySelector(`#${CSS.escape(id)}`); - if (view) { - const container = document.createElement('span'); - container.className = 'md-inline-view'; - const vAlign = (view as HTMLElement).getAttribute('vertical-align') - || (view as HTMLElement).style.verticalAlign - || ''; - if (vAlign) { - (container.style as any).verticalAlign = vAlign; - } - const slot = document.createElement('slot'); - const slotName = `md-inline-view-${id}`; - slot.name = slotName; - (view as HTMLElement).slot = slotName; - container.appendChild(slot); - img.replaceWith(container); - } + const container = document.createElement('span'); + container.className = 'md-inline-view'; + const slot = document.createElement('slot'); + slot.name = `md-inline-view-${id}`; + container.appendChild(slot); + img.replaceWith(container); } } } catch { diff --git a/packages/web-platform/web-elements/tests/fixtures/x-markdown/inlineview-class.html b/packages/web-platform/web-elements/tests/fixtures/x-markdown/inlineview-class.html index f6be0c5dc3..5989d77763 100644 --- a/packages/web-platform/web-elements/tests/fixtures/x-markdown/inlineview-class.html +++ b/packages/web-platform/web-elements/tests/fixtures/x-markdown/inlineview-class.html @@ -18,7 +18,11 @@ - +