frosty 0.0.37 → 0.0.39
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 +2 -1
- package/dist/dom.js +1 -1
- package/dist/dom.mjs +1 -1
- package/dist/internals/{common-D44KuOmi.d.ts → common-Dgt9gkTj.d.ts} +6 -4
- package/dist/internals/common-Dgt9gkTj.d.ts.map +1 -0
- package/dist/internals/{common-BoxPKJqo.mjs → common-Dz0g-ZKV.mjs} +21 -18
- package/dist/internals/{common-BoxPKJqo.mjs.map → common-Dz0g-ZKV.mjs.map} +1 -1
- package/dist/internals/{common-CRYEvU6P.js → common-Q9Xz4i4m.js} +21 -18
- package/dist/internals/{common-CRYEvU6P.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 +6 -4
- package/dist/web.js +56 -42
- package/dist/web.js.map +1 -1
- package/dist/web.mjs +57 -44
- package/dist/web.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/internals/common-D44KuOmi.d.ts.map +0 -1
|
@@ -3894,19 +3894,22 @@ class DOMNativeNode extends component.NativeElementType {
|
|
|
3894
3894
|
static createElement;
|
|
3895
3895
|
}
|
|
3896
3896
|
class _DOMRenderer extends renderer._Renderer {
|
|
3897
|
-
|
|
3897
|
+
_window;
|
|
3898
3898
|
_namespace_map = new WeakMap();
|
|
3899
3899
|
_tracked_props = new WeakMap();
|
|
3900
3900
|
_tracked_listener = new WeakMap();
|
|
3901
3901
|
_tracked_head_children = [];
|
|
3902
3902
|
_tracked_style = new StyleBuilder();
|
|
3903
3903
|
_tracked_style_names = [];
|
|
3904
|
-
constructor(
|
|
3904
|
+
constructor(window) {
|
|
3905
3905
|
super();
|
|
3906
|
-
this.
|
|
3906
|
+
this._window = window;
|
|
3907
3907
|
}
|
|
3908
|
-
get
|
|
3909
|
-
return this.
|
|
3908
|
+
get document() {
|
|
3909
|
+
return this.window.document;
|
|
3910
|
+
}
|
|
3911
|
+
get window() {
|
|
3912
|
+
return this._window ?? window;
|
|
3910
3913
|
}
|
|
3911
3914
|
/** @internal */
|
|
3912
3915
|
_beforeUpdate() {
|
|
@@ -3920,18 +3923,18 @@ class _DOMRenderer extends renderer._Renderer {
|
|
|
3920
3923
|
this._tracked_style.select(this._tracked_style_names);
|
|
3921
3924
|
if (this._tracked_style.isEmpty) {
|
|
3922
3925
|
if (this._server) {
|
|
3923
|
-
this.__replaceChildren(this.
|
|
3926
|
+
this.__replaceChildren(this.document.head, this._tracked_head_children);
|
|
3924
3927
|
}
|
|
3925
3928
|
}
|
|
3926
3929
|
else {
|
|
3927
|
-
const styleElem = this.
|
|
3930
|
+
const styleElem = this.document.querySelector('style[data-frosty-style]') ?? this.document.createElementNS(HTML_NS, 'style');
|
|
3928
3931
|
styleElem.setAttribute('data-frosty-style', '');
|
|
3929
3932
|
styleElem.textContent = this._tracked_style.css;
|
|
3930
3933
|
if (this._server) {
|
|
3931
|
-
this.__replaceChildren(this.
|
|
3934
|
+
this.__replaceChildren(this.document.head, [...this._tracked_head_children, styleElem]);
|
|
3932
3935
|
}
|
|
3933
|
-
else if (styleElem.parentNode !== this.
|
|
3934
|
-
this.
|
|
3936
|
+
else if (styleElem.parentNode !== this.document.head) {
|
|
3937
|
+
this.document.head.appendChild(styleElem);
|
|
3935
3938
|
}
|
|
3936
3939
|
}
|
|
3937
3940
|
}
|
|
@@ -3940,16 +3943,16 @@ class _DOMRenderer extends renderer._Renderer {
|
|
|
3940
3943
|
const { type } = node;
|
|
3941
3944
|
if (!_.isString(type) && type.prototype instanceof DOMNativeNode) {
|
|
3942
3945
|
const ElementType = type;
|
|
3943
|
-
const elem = ElementType.createElement(this.
|
|
3946
|
+
const elem = ElementType.createElement(this.document, this);
|
|
3944
3947
|
this._updateElement(node, elem, stack);
|
|
3945
3948
|
return elem;
|
|
3946
3949
|
}
|
|
3947
3950
|
if (!_.isString(type))
|
|
3948
3951
|
throw Error('Invalid type');
|
|
3949
3952
|
switch (type) {
|
|
3950
|
-
case 'html': return this.
|
|
3951
|
-
case 'head': return this.
|
|
3952
|
-
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');
|
|
3953
3956
|
}
|
|
3954
3957
|
const _ns_list = _.compact([
|
|
3955
3958
|
_.includes(tags.svg, type) && SVG_NS,
|
|
@@ -3958,7 +3961,7 @@ class _DOMRenderer extends renderer._Renderer {
|
|
|
3958
3961
|
]);
|
|
3959
3962
|
const parent = _.last(stack);
|
|
3960
3963
|
const ns = _ns_list.length > 1 ? parent && _.first(_.intersection([this._namespace_map.get(parent)], _ns_list)) : _.first(_ns_list);
|
|
3961
|
-
const elem = ns ? this.
|
|
3964
|
+
const elem = ns ? this.document.createElementNS(ns, type) : this.document.createElement(type);
|
|
3962
3965
|
this._namespace_map.set(node, ns);
|
|
3963
3966
|
this._updateElement(node, elem, stack);
|
|
3964
3967
|
return elem;
|
|
@@ -4098,7 +4101,7 @@ class _DOMRenderer extends renderer._Renderer {
|
|
|
4098
4101
|
}
|
|
4099
4102
|
}
|
|
4100
4103
|
__replaceChildren(element, children) {
|
|
4101
|
-
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 });
|
|
4102
4105
|
let i = 0;
|
|
4103
4106
|
for (const { remove, insert, equivalent } of diff) {
|
|
4104
4107
|
if (equivalent) {
|
|
@@ -4111,7 +4114,7 @@ class _DOMRenderer extends renderer._Renderer {
|
|
|
4111
4114
|
}
|
|
4112
4115
|
if (insert) {
|
|
4113
4116
|
for (const child of insert) {
|
|
4114
|
-
const node = _.isString(child) ? this.
|
|
4117
|
+
const node = _.isString(child) ? this.document.createTextNode(child) : child;
|
|
4115
4118
|
element.insertBefore(node, element.childNodes[i++]);
|
|
4116
4119
|
}
|
|
4117
4120
|
}
|
|
@@ -4132,4 +4135,4 @@ class _DOMRenderer extends renderer._Renderer {
|
|
|
4132
4135
|
|
|
4133
4136
|
exports.DOMNativeNode = DOMNativeNode;
|
|
4134
4137
|
exports._DOMRenderer = _DOMRenderer;
|
|
4135
|
-
//# sourceMappingURL=common-
|
|
4138
|
+
//# sourceMappingURL=common-Q9Xz4i4m.js.map
|