diff --git a/jsr.json b/jsr.json index 58237ed..a5c8814 100644 --- a/jsr.json +++ b/jsr.json @@ -1,5 +1,5 @@ { "name": "@worldmaker/butterfloat", - "version": "1.6.3", + "version": "1.6.4", "exports": "./index.ts" } diff --git a/package.json b/package.json index 7f07d90..0fbcdf6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "type": "module", "name": "butterfloat", - "version": "1.6.3", + "version": "1.6.4", "description": "Knockout-inspired view engine for RxJS with TSX", "homepage": "https://worldmaker.net/butterfloat/", "repository": "github:WorldMaker/butterfloat", diff --git a/wiring-dom-only-stamp.ts b/wiring-dom-only-stamp.ts index 2cc0483..aed43b6 100644 --- a/wiring-dom-only-stamp.ts +++ b/wiring-dom-only-stamp.ts @@ -10,7 +10,7 @@ const stampOnlyStrategy: (stamps: StampCollection) => DomStrategy = properties: unknown, context: ComponentContext, container: Element | DocumentFragment | undefined, - _document: Document, + document: Document, ) => { if (container && stamps.isPrestamp(component, properties, container)) { return { @@ -20,7 +20,18 @@ const stampOnlyStrategy: (stamps: StampCollection) => DomStrategy = } const stamp = stamps.getStamp(component, properties) if (stamp) { - const container = stamp.content.cloneNode(true) as DocumentFragment + let container = document.importNode(stamp.content, true) as + | Element + | DocumentFragment + if ( + container.nodeType === container.DOCUMENT_FRAGMENT_NODE && + container.children.length === 1 + ) { + const child = container.firstElementChild + if (child) { + container = child + } + } return { ...selectBindings(container, component(properties, context)), isSameContainer: false, diff --git a/wiring-dom-stamp.ts b/wiring-dom-stamp.ts index 943c3ae..1d48e2c 100644 --- a/wiring-dom-stamp.ts +++ b/wiring-dom-stamp.ts @@ -21,7 +21,7 @@ const stampOrBuildStrategy: (stamps: StampCollection) => DomStrategy = } const stamp = stamps.getStamp(component, properties) if (stamp) { - let container = stamp.content.cloneNode(true) as + let container = document.importNode(stamp.content, true) as | Element | DocumentFragment if (