ember-source 6.0.0-alpha.9 → 6.0.0

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.
@@ -6,45 +6,29 @@ class NodeDOMTreeConstruction extends DOMTreeConstruction {
6
6
  constructor(doc) {
7
7
  super(doc || createHTMLDocument());
8
8
  }
9
-
10
9
  // override to prevent usage of `this.document` until after the constructor
11
10
  setupUselessElement() {}
12
11
  insertHTMLBefore(parent, reference, html) {
13
12
  let raw = this.document.createRawHTMLSection(html);
14
- parent.insertBefore(raw, reference);
15
- return new ConcreteBounds(parent, raw, raw);
13
+ return parent.insertBefore(raw, reference), new ConcreteBounds(parent, raw, raw);
16
14
  }
17
-
18
15
  // override to avoid SVG detection/work when in node (this is not needed in SSR)
19
16
  createElement(tag) {
20
17
  return this.document.createElement(tag);
21
18
  }
22
-
23
19
  // override to avoid namespace shenanigans when in node (this is not needed in SSR)
24
20
  setAttribute(element, name, value) {
25
21
  element.setAttribute(name, value);
26
22
  }
27
23
  }
28
- const TEXT_NODE = 3;
29
24
  const NEEDS_EXTRA_CLOSE = new WeakMap();
30
- function currentNode(cursor) {
31
- let {
32
- element,
33
- nextSibling
34
- } = cursor;
35
- if (nextSibling === null) {
36
- return element.lastChild;
37
- } else {
38
- return nextSibling.previousSibling;
39
- }
40
- }
41
25
  class SerializeBuilder extends NewElementBuilder {
42
26
  serializeBlockDepth = 0;
43
27
  __openBlock() {
44
28
  let {
45
- tagName
29
+ tagName: tagName
46
30
  } = this.element;
47
- if (tagName !== 'TITLE' && tagName !== 'SCRIPT' && tagName !== 'STYLE') {
31
+ if ("TITLE" !== tagName && "SCRIPT" !== tagName && "STYLE" !== tagName) {
48
32
  let depth = this.serializeBlockDepth++;
49
33
  this.__appendComment(`%+b:${depth}%`);
50
34
  }
@@ -52,84 +36,58 @@ class SerializeBuilder extends NewElementBuilder {
52
36
  }
53
37
  __closeBlock() {
54
38
  let {
55
- tagName
39
+ tagName: tagName
56
40
  } = this.element;
57
- super.__closeBlock();
58
- if (tagName !== 'TITLE' && tagName !== 'SCRIPT' && tagName !== 'STYLE') {
41
+ if (super.__closeBlock(), "TITLE" !== tagName && "SCRIPT" !== tagName && "STYLE" !== tagName) {
59
42
  let depth = --this.serializeBlockDepth;
60
43
  this.__appendComment(`%-b:${depth}%`);
61
44
  }
62
45
  }
63
46
  __appendHTML(html) {
64
47
  let {
65
- tagName
48
+ tagName: tagName
66
49
  } = this.element;
67
- if (tagName === 'TITLE' || tagName === 'SCRIPT' || tagName === 'STYLE') {
68
- return super.__appendHTML(html);
69
- }
70
-
50
+ if ("TITLE" === tagName || "SCRIPT" === tagName || "STYLE" === tagName) return super.__appendHTML(html);
71
51
  // Do we need to run the html tokenizer here?
72
- let first = this.__appendComment('%glmr%');
73
- if (tagName === 'TABLE') {
74
- let openIndex = html.indexOf('<');
75
- if (openIndex > -1) {
76
- let tr = html.slice(openIndex + 1, openIndex + 3);
77
- if (tr === 'tr') {
78
- html = `<tbody>${html}</tbody>`;
79
- }
80
- }
81
- }
82
- if (html === '') {
83
- this.__appendComment('% %');
84
- } else {
85
- super.__appendHTML(html);
52
+ let first = this.__appendComment("%glmr%");
53
+ if ("TABLE" === tagName) {
54
+ let openIndex = html.indexOf("<");
55
+ openIndex > -1 && "tr" === html.slice(openIndex + 1, openIndex + 3) && (html = `<tbody>${html}</tbody>`);
86
56
  }
87
- let last = this.__appendComment('%glmr%');
57
+ "" === html ? this.__appendComment("% %") : super.__appendHTML(html);
58
+ let last = this.__appendComment("%glmr%");
88
59
  return new ConcreteBounds(this.element, first, last);
89
60
  }
90
61
  __appendText(string) {
91
62
  let {
92
- tagName
93
- } = this.element;
94
- let current = currentNode(this);
95
- if (tagName === 'TITLE' || tagName === 'SCRIPT' || tagName === 'STYLE') {
96
- return super.__appendText(string);
97
- } else if (string === '') {
98
- return this.__appendComment('% %');
99
- } else if (current && current.nodeType === TEXT_NODE) {
100
- this.__appendComment('%|%');
101
- }
102
- return super.__appendText(string);
63
+ tagName: tagName
64
+ } = this.element,
65
+ current = function (cursor) {
66
+ let {
67
+ element: element,
68
+ nextSibling: nextSibling
69
+ } = cursor;
70
+ return null === nextSibling ? element.lastChild : nextSibling.previousSibling;
71
+ }(this);
72
+ return "TITLE" === tagName || "SCRIPT" === tagName || "STYLE" === tagName ? super.__appendText(string) : "" === string ? this.__appendComment("% %") : (current && 3 === current.nodeType && this.__appendComment("%|%"), super.__appendText(string));
103
73
  }
104
74
  closeElement() {
105
- if (NEEDS_EXTRA_CLOSE.has(this.element)) {
106
- NEEDS_EXTRA_CLOSE.delete(this.element);
107
- super.closeElement();
108
- }
109
- return super.closeElement();
75
+ return NEEDS_EXTRA_CLOSE.has(this.element) && (NEEDS_EXTRA_CLOSE.delete(this.element), super.closeElement()), super.closeElement();
110
76
  }
111
77
  openElement(tag) {
112
- if (tag === 'tr') {
113
- if (this.element.tagName !== 'TBODY' && this.element.tagName !== 'THEAD' && this.element.tagName !== 'TFOOT') {
114
- this.openElement('tbody');
115
- // This prevents the closeBlock comment from being re-parented
116
- // under the auto inserted tbody. Rehydration builder needs to
117
- // account for the insertion since it is injected here and not
118
- // really in the template.
119
- NEEDS_EXTRA_CLOSE.set(this.constructing, true);
120
- this.flushElement(null);
121
- }
122
- }
123
- return super.openElement(tag);
78
+ return "tr" === tag && "TBODY" !== this.element.tagName && "THEAD" !== this.element.tagName && "TFOOT" !== this.element.tagName && (this.openElement("tbody"),
79
+ // This prevents the closeBlock comment from being re-parented
80
+ // under the auto inserted tbody. Rehydration builder needs to
81
+ // account for the insertion since it is injected here and not
82
+ // really in the template.
83
+ NEEDS_EXTRA_CLOSE.set(this.constructing, !0), this.flushElement(null)), super.openElement(tag);
124
84
  }
125
85
  pushRemoteElement(element, cursorId, insertBefore = null) {
126
86
  let {
127
- dom
128
- } = this;
129
- let script = dom.createElement('script');
130
- script.setAttribute('glmr', cursorId);
131
- dom.insertBefore(element, script, insertBefore);
132
- return super.pushRemoteElement(element, cursorId, insertBefore);
87
+ dom: dom
88
+ } = this,
89
+ script = dom.createElement("script");
90
+ return script.setAttribute("glmr", cursorId), dom.insertBefore(element, script, insertBefore), super.pushRemoteElement(element, cursorId, insertBefore);
133
91
  }
134
92
  }
135
93
  function serializeBuilder(env, cursor) {