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.
@@ -3894,19 +3894,22 @@ class DOMNativeNode extends component.NativeElementType {
3894
3894
  static createElement;
3895
3895
  }
3896
3896
  class _DOMRenderer extends renderer._Renderer {
3897
- _doc;
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(doc) {
3904
+ constructor(window) {
3905
3905
  super();
3906
- this._doc = doc;
3906
+ this._window = window;
3907
3907
  }
3908
- get doc() {
3909
- return this._doc ?? document;
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.doc.head, this._tracked_head_children);
3926
+ this.__replaceChildren(this.document.head, this._tracked_head_children);
3924
3927
  }
3925
3928
  }
3926
3929
  else {
3927
- const styleElem = this.doc.querySelector('style[data-frosty-style]') ?? this.doc.createElementNS(HTML_NS, 'style');
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.doc.head, [...this._tracked_head_children, styleElem]);
3934
+ this.__replaceChildren(this.document.head, [...this._tracked_head_children, styleElem]);
3932
3935
  }
3933
- else if (styleElem.parentNode !== this.doc.head) {
3934
- this.doc.head.appendChild(styleElem);
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.doc, 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.doc.documentElement;
3951
- case 'head': return this.doc.head ?? this.doc.createElementNS(HTML_NS, 'head');
3952
- case 'body': return this.doc.body ?? this.doc.createElementNS(HTML_NS, 'body');
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.doc.createElementNS(ns, type) : this.doc.createElement(type);
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.doc.TEXT_NODE ? x.textContent ?? '' : x), _.map(children, x => x instanceof DOMNativeNode ? x.target : x), { compare: (a, b) => a === b });
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.doc.createTextNode(child) : child;
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-CRYEvU6P.js.map
4138
+ //# sourceMappingURL=common-Q9Xz4i4m.js.map