frosty 0.0.38 → 0.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +1 -1
- package/dist/dom.mjs +1 -1
- package/dist/internals/{common-k6qbeyHu.d.ts → common-Dgt9gkTj.d.ts} +3 -4
- package/dist/internals/common-Dgt9gkTj.d.ts.map +1 -0
- package/dist/internals/{common-CFQAs-2w.mjs → common-Dz0g-ZKV.mjs} +16 -18
- package/dist/internals/{common-CFQAs-2w.mjs.map → common-Dz0g-ZKV.mjs.map} +1 -1
- package/dist/internals/{common-P_QiOxQQ.js → common-Q9Xz4i4m.js} +16 -18
- package/dist/internals/{common-P_QiOxQQ.js.map → common-Q9Xz4i4m.js.map} +1 -1
- package/dist/server-dom.d.ts +1 -1
- package/dist/server-dom.js +2 -2
- package/dist/server-dom.js.map +1 -1
- package/dist/server-dom.mjs +2 -2
- package/dist/server-dom.mjs.map +1 -1
- package/dist/web.d.ts +2 -2
- package/dist/web.js +47 -45
- package/dist/web.js.map +1 -1
- package/dist/web.mjs +48 -46
- package/dist/web.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/internals/common-k6qbeyHu.d.ts.map +0 -1
|
@@ -3894,7 +3894,6 @@ class DOMNativeNode extends component.NativeElementType {
|
|
|
3894
3894
|
static createElement;
|
|
3895
3895
|
}
|
|
3896
3896
|
class _DOMRenderer extends renderer._Renderer {
|
|
3897
|
-
_doc;
|
|
3898
3897
|
_window;
|
|
3899
3898
|
_namespace_map = new WeakMap();
|
|
3900
3899
|
_tracked_props = new WeakMap();
|
|
@@ -3902,13 +3901,12 @@ class _DOMRenderer extends renderer._Renderer {
|
|
|
3902
3901
|
_tracked_head_children = [];
|
|
3903
3902
|
_tracked_style = new StyleBuilder();
|
|
3904
3903
|
_tracked_style_names = [];
|
|
3905
|
-
constructor(
|
|
3904
|
+
constructor(window) {
|
|
3906
3905
|
super();
|
|
3907
|
-
this._doc = doc;
|
|
3908
3906
|
this._window = window;
|
|
3909
3907
|
}
|
|
3910
|
-
get
|
|
3911
|
-
return this.
|
|
3908
|
+
get document() {
|
|
3909
|
+
return this.window.document;
|
|
3912
3910
|
}
|
|
3913
3911
|
get window() {
|
|
3914
3912
|
return this._window ?? window;
|
|
@@ -3925,18 +3923,18 @@ class _DOMRenderer extends renderer._Renderer {
|
|
|
3925
3923
|
this._tracked_style.select(this._tracked_style_names);
|
|
3926
3924
|
if (this._tracked_style.isEmpty) {
|
|
3927
3925
|
if (this._server) {
|
|
3928
|
-
this.__replaceChildren(this.
|
|
3926
|
+
this.__replaceChildren(this.document.head, this._tracked_head_children);
|
|
3929
3927
|
}
|
|
3930
3928
|
}
|
|
3931
3929
|
else {
|
|
3932
|
-
const styleElem = this.
|
|
3930
|
+
const styleElem = this.document.querySelector('style[data-frosty-style]') ?? this.document.createElementNS(HTML_NS, 'style');
|
|
3933
3931
|
styleElem.setAttribute('data-frosty-style', '');
|
|
3934
3932
|
styleElem.textContent = this._tracked_style.css;
|
|
3935
3933
|
if (this._server) {
|
|
3936
|
-
this.__replaceChildren(this.
|
|
3934
|
+
this.__replaceChildren(this.document.head, [...this._tracked_head_children, styleElem]);
|
|
3937
3935
|
}
|
|
3938
|
-
else if (styleElem.parentNode !== this.
|
|
3939
|
-
this.
|
|
3936
|
+
else if (styleElem.parentNode !== this.document.head) {
|
|
3937
|
+
this.document.head.appendChild(styleElem);
|
|
3940
3938
|
}
|
|
3941
3939
|
}
|
|
3942
3940
|
}
|
|
@@ -3945,16 +3943,16 @@ class _DOMRenderer extends renderer._Renderer {
|
|
|
3945
3943
|
const { type } = node;
|
|
3946
3944
|
if (!_.isString(type) && type.prototype instanceof DOMNativeNode) {
|
|
3947
3945
|
const ElementType = type;
|
|
3948
|
-
const elem = ElementType.createElement(this.
|
|
3946
|
+
const elem = ElementType.createElement(this.document, this);
|
|
3949
3947
|
this._updateElement(node, elem, stack);
|
|
3950
3948
|
return elem;
|
|
3951
3949
|
}
|
|
3952
3950
|
if (!_.isString(type))
|
|
3953
3951
|
throw Error('Invalid type');
|
|
3954
3952
|
switch (type) {
|
|
3955
|
-
case 'html': return this.
|
|
3956
|
-
case 'head': return this.
|
|
3957
|
-
case 'body': return this.
|
|
3953
|
+
case 'html': return this.document.documentElement;
|
|
3954
|
+
case 'head': return this.document.head ?? this.document.createElementNS(HTML_NS, 'head');
|
|
3955
|
+
case 'body': return this.document.body ?? this.document.createElementNS(HTML_NS, 'body');
|
|
3958
3956
|
}
|
|
3959
3957
|
const _ns_list = _.compact([
|
|
3960
3958
|
_.includes(tags.svg, type) && SVG_NS,
|
|
@@ -3963,7 +3961,7 @@ class _DOMRenderer extends renderer._Renderer {
|
|
|
3963
3961
|
]);
|
|
3964
3962
|
const parent = _.last(stack);
|
|
3965
3963
|
const ns = _ns_list.length > 1 ? parent && _.first(_.intersection([this._namespace_map.get(parent)], _ns_list)) : _.first(_ns_list);
|
|
3966
|
-
const elem = ns ? this.
|
|
3964
|
+
const elem = ns ? this.document.createElementNS(ns, type) : this.document.createElement(type);
|
|
3967
3965
|
this._namespace_map.set(node, ns);
|
|
3968
3966
|
this._updateElement(node, elem, stack);
|
|
3969
3967
|
return elem;
|
|
@@ -4103,7 +4101,7 @@ class _DOMRenderer extends renderer._Renderer {
|
|
|
4103
4101
|
}
|
|
4104
4102
|
}
|
|
4105
4103
|
__replaceChildren(element, children) {
|
|
4106
|
-
const diff = myers_js.myersSync(_.map(element.childNodes, x => x.nodeType === this.
|
|
4104
|
+
const diff = myers_js.myersSync(_.map(element.childNodes, x => x.nodeType === this.document.TEXT_NODE ? x.textContent ?? '' : x), _.map(children, x => x instanceof DOMNativeNode ? x.target : x), { compare: (a, b) => a === b });
|
|
4107
4105
|
let i = 0;
|
|
4108
4106
|
for (const { remove, insert, equivalent } of diff) {
|
|
4109
4107
|
if (equivalent) {
|
|
@@ -4116,7 +4114,7 @@ class _DOMRenderer extends renderer._Renderer {
|
|
|
4116
4114
|
}
|
|
4117
4115
|
if (insert) {
|
|
4118
4116
|
for (const child of insert) {
|
|
4119
|
-
const node = _.isString(child) ? this.
|
|
4117
|
+
const node = _.isString(child) ? this.document.createTextNode(child) : child;
|
|
4120
4118
|
element.insertBefore(node, element.childNodes[i++]);
|
|
4121
4119
|
}
|
|
4122
4120
|
}
|
|
@@ -4137,4 +4135,4 @@ class _DOMRenderer extends renderer._Renderer {
|
|
|
4137
4135
|
|
|
4138
4136
|
exports.DOMNativeNode = DOMNativeNode;
|
|
4139
4137
|
exports._DOMRenderer = _DOMRenderer;
|
|
4140
|
-
//# sourceMappingURL=common-
|
|
4138
|
+
//# sourceMappingURL=common-Q9Xz4i4m.js.map
|