diff --git a/site/views/examples/example/text.njk b/site/views/examples/example/text.njk index e165c190..78469a57 100644 --- a/site/views/examples/example/text.njk +++ b/site/views/examples/example/text.njk @@ -6,8 +6,14 @@ title: Example with dummy text (pre-processors) + + diff --git a/src/core/base/model.ts b/src/core/base/model.ts index 868b6c5f..713e3be3 100644 --- a/src/core/base/model.ts +++ b/src/core/base/model.ts @@ -91,8 +91,16 @@ export class UIPStateModel extends SyntheticEventTarget { */ public setHtml(markup: string, modifier: UIPPlugin | UIPRoot, force: boolean = false): void { const html = UIPHTMLNormalizationPreprocessors.preprocess(markup); - const root = new DOMParser().parseFromString(html, 'text/html').body; - if (!root || root.innerHTML.trim() !== this.html.trim()) { + const {head, body: root} = new DOMParser().parseFromString(html, 'text/html'); + + Array.from(head.children).reverse().forEach((el) => { + if (el.tagName === 'STYLE') { + root.innerHTML = '\n' + root.innerHTML; + root.insertBefore(el, root.firstChild); + } + }); + + if (root.innerHTML.trim() !== this.html.trim()) { this._html = root; this._changes.push({modifier, type: 'html', force}); this.dispatchChange();