@itrocks/template 0.0.19 → 0.0.21

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/cjs/template.js CHANGED
@@ -155,6 +155,7 @@ class Template {
155
155
  template.doExpression = this.doExpression;
156
156
  template.doHeadLinks = true;
157
157
  template.doLiteral = this.doLiteral;
158
+ template.doneLinks = this.headLinks;
158
159
  template.included = true;
159
160
  template.onAttribute = this.onAttribute;
160
161
  template.onTagClose = this.onTagClose;
@@ -165,6 +166,8 @@ class Template {
165
166
  const parsed = await template.parseFile(((path[0] === node_path_1.sep) || (path[1] === ':'))
166
167
  ? path
167
168
  : (this.filePath + node_path_1.sep + path));
169
+ this.headLinks.push(...template.headLinks);
170
+ this.headTitle = template.headTitle;
168
171
  return parsed.substring(parsed.indexOf('<!--BEGIN-->') + 12, parsed.indexOf('<!--END-->'));
169
172
  }
170
173
  isContextClean() {
@@ -210,10 +213,6 @@ class Template {
210
213
  if (this.headLinks.length) {
211
214
  const position = this.target.lastIndexOf('>', this.target.indexOf('</head>')) + 1;
212
215
  this.target = this.target.slice(0, position) + '\n\t' + this.headLinks.join('\n\t') + this.target.slice(position);
213
- this.doneLinks = new sorted_array_1.SortedArray;
214
- this.headLinks = new sorted_array_1.SortedArray;
215
- this.doneLinks.distinct = true;
216
- this.headLinks.distinct = true;
217
216
  }
218
217
  if (this.headTitle && !this.included) {
219
218
  const position = this.target.indexOf('>', this.target.indexOf('<title') + 6) + 1;
@@ -504,11 +503,6 @@ class Template {
504
503
  this.index += closeTagName.length + 1;
505
504
  if (inHead && (closeTagName[0] === 'h') && (closeTagName === 'head')) {
506
505
  inHead = false;
507
- if (!this.doHeadLinks) {
508
- this.doneLinks = this.headLinks;
509
- this.headLinks = new sorted_array_1.SortedArray();
510
- this.headLinks.distinct = true;
511
- }
512
506
  }
513
507
  let shouldInLiteral = this.inLiteral;
514
508
  if (!this.unclosingTags.includes(closeTagName)) {
@@ -623,7 +617,7 @@ class Template {
623
617
  // end of attribute value
624
618
  if (shortQuote ? (char === quote) : quote.includes(char)) {
625
619
  const attributeValue = this.source.substring(position, this.index);
626
- if (inInput && (hasTypeSubmit === undefined)) {
620
+ if (inInput && !hasTypeSubmit) {
627
621
  hasTypeSubmit = (attributeChar === 't') && (attributeValue[0] === 's')
628
622
  && (attributeName === 'type') && (attributeValue === 'submit');
629
623
  }
@@ -686,7 +680,7 @@ class Template {
686
680
  if (targetTagIndex > -1) {
687
681
  this.sourceToTarget();
688
682
  const headLink = this.target.substring(targetTagIndex);
689
- if (!this.doneLinks || !this.doneLinks.includes(headLink)) {
683
+ if (!this.doneLinks.includes(headLink)) {
690
684
  this.headLinks.insert(headLink);
691
685
  }
692
686
  }
package/esm/template.js CHANGED
@@ -150,6 +150,7 @@ export default class Template {
150
150
  template.doExpression = this.doExpression;
151
151
  template.doHeadLinks = true;
152
152
  template.doLiteral = this.doLiteral;
153
+ template.doneLinks = this.headLinks;
153
154
  template.included = true;
154
155
  template.onAttribute = this.onAttribute;
155
156
  template.onTagClose = this.onTagClose;
@@ -160,6 +161,8 @@ export default class Template {
160
161
  const parsed = await template.parseFile(((path[0] === sep) || (path[1] === ':'))
161
162
  ? path
162
163
  : (this.filePath + sep + path));
164
+ this.headLinks.push(...template.headLinks);
165
+ this.headTitle = template.headTitle;
163
166
  return parsed.substring(parsed.indexOf('<!--BEGIN-->') + 12, parsed.indexOf('<!--END-->'));
164
167
  }
165
168
  isContextClean() {
@@ -205,10 +208,6 @@ export default class Template {
205
208
  if (this.headLinks.length) {
206
209
  const position = this.target.lastIndexOf('>', this.target.indexOf('</head>')) + 1;
207
210
  this.target = this.target.slice(0, position) + '\n\t' + this.headLinks.join('\n\t') + this.target.slice(position);
208
- this.doneLinks = new SortedArray;
209
- this.headLinks = new SortedArray;
210
- this.doneLinks.distinct = true;
211
- this.headLinks.distinct = true;
212
211
  }
213
212
  if (this.headTitle && !this.included) {
214
213
  const position = this.target.indexOf('>', this.target.indexOf('<title') + 6) + 1;
@@ -499,11 +498,6 @@ export default class Template {
499
498
  this.index += closeTagName.length + 1;
500
499
  if (inHead && (closeTagName[0] === 'h') && (closeTagName === 'head')) {
501
500
  inHead = false;
502
- if (!this.doHeadLinks) {
503
- this.doneLinks = this.headLinks;
504
- this.headLinks = new SortedArray();
505
- this.headLinks.distinct = true;
506
- }
507
501
  }
508
502
  let shouldInLiteral = this.inLiteral;
509
503
  if (!this.unclosingTags.includes(closeTagName)) {
@@ -618,7 +612,7 @@ export default class Template {
618
612
  // end of attribute value
619
613
  if (shortQuote ? (char === quote) : quote.includes(char)) {
620
614
  const attributeValue = this.source.substring(position, this.index);
621
- if (inInput && (hasTypeSubmit === undefined)) {
615
+ if (inInput && !hasTypeSubmit) {
622
616
  hasTypeSubmit = (attributeChar === 't') && (attributeValue[0] === 's')
623
617
  && (attributeName === 'type') && (attributeValue === 'submit');
624
618
  }
@@ -681,7 +675,7 @@ export default class Template {
681
675
  if (targetTagIndex > -1) {
682
676
  this.sourceToTarget();
683
677
  const headLink = this.target.substring(targetTagIndex);
684
- if (!this.doneLinks || !this.doneLinks.includes(headLink)) {
678
+ if (!this.doneLinks.includes(headLink)) {
685
679
  this.headLinks.insert(headLink);
686
680
  }
687
681
  }
package/package.json CHANGED
@@ -60,5 +60,5 @@
60
60
  "test": "jest"
61
61
  },
62
62
  "types": "./esm/template.d.ts",
63
- "version": "0.0.19"
63
+ "version": "0.0.21"
64
64
  }