@wavemaker/angular-codegen 11.14.1-3.6306 → 11.14.1-30.647738

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.
@@ -33117,7 +33117,7 @@ function verifySemanticsOfNgModuleDef$1(moduleType, allowDuplicateDeclarationsIn
33117
33117
  verifySemanticsOfNgModuleImport(modOrStandaloneCmpt, moduleType);
33118
33118
  verifySemanticsOfNgModuleDef$1(modOrStandaloneCmpt, false, moduleType);
33119
33119
  });
33120
- const exports$1 = maybeUnwrapFn$1(ngModuleDef.exports);
33120
+ const exports = maybeUnwrapFn$1(ngModuleDef.exports);
33121
33121
  declarations.forEach(verifyDeclarationsHaveDefinitions);
33122
33122
  declarations.forEach(verifyDirectivesHaveSelector);
33123
33123
  declarations.forEach((declarationType) => verifyNotStandalone(declarationType, moduleType));
@@ -33125,7 +33125,7 @@ function verifySemanticsOfNgModuleDef$1(moduleType, allowDuplicateDeclarationsIn
33125
33125
  ...declarations.map(resolveForwardRef$1),
33126
33126
  ...flatten$3(imports.map(computeCombinedExports$1)).map(resolveForwardRef$1),
33127
33127
  ];
33128
- exports$1.forEach(verifyExportsAreDeclaredOrReExported);
33128
+ exports.forEach(verifyExportsAreDeclaredOrReExported);
33129
33129
  declarations.forEach((decl) => verifyDeclarationIsUnique(decl, allowDuplicateDeclarationsInRoot));
33130
33130
  const ngModule = getAnnotation$1(moduleType, 'NgModule');
33131
33131
  if (ngModule) {
@@ -81193,7 +81193,7 @@ function verifySemanticsOfNgModuleDef(moduleType, allowDuplicateDeclarationsInRo
81193
81193
  verifySemanticsOfNgModuleImport(modOrStandaloneCmpt, moduleType);
81194
81194
  verifySemanticsOfNgModuleDef(modOrStandaloneCmpt, false, moduleType);
81195
81195
  });
81196
- const exports$1 = maybeUnwrapFn(ngModuleDef.exports);
81196
+ const exports = maybeUnwrapFn(ngModuleDef.exports);
81197
81197
  declarations.forEach(verifyDeclarationsHaveDefinitions);
81198
81198
  declarations.forEach(verifyDirectivesHaveSelector);
81199
81199
  declarations.forEach((declarationType) => verifyNotStandalone(declarationType, moduleType));
@@ -81201,7 +81201,7 @@ function verifySemanticsOfNgModuleDef(moduleType, allowDuplicateDeclarationsInRo
81201
81201
  ...declarations.map(resolveForwardRef),
81202
81202
  ...flatten$1(imports.map(computeCombinedExports)).map(resolveForwardRef),
81203
81203
  ];
81204
- exports$1.forEach(verifyExportsAreDeclaredOrReExported);
81204
+ exports.forEach(verifyExportsAreDeclaredOrReExported);
81205
81205
  declarations.forEach((decl) => verifyDeclarationIsUnique(decl, allowDuplicateDeclarationsInRoot));
81206
81206
  const ngModule = getAnnotation(moduleType, 'NgModule');
81207
81207
  if (ngModule) {
@@ -102019,14 +102019,14 @@ function createNgModuleType$1(meta) {
102019
102019
  if (meta.kind === R3NgModuleMetadataKind$1.Local) {
102020
102020
  return new ExpressionType$1$1(meta.type.value);
102021
102021
  }
102022
- const { type: moduleType, declarations, exports: exports$1, imports, includeImportTypes, publicDeclarationTypes, } = meta;
102022
+ const { type: moduleType, declarations, exports, imports, includeImportTypes, publicDeclarationTypes, } = meta;
102023
102023
  return new ExpressionType$1$1(importExpr$1(Identifiers$1.NgModuleDeclaration, [
102024
102024
  new ExpressionType$1$1(moduleType.type),
102025
102025
  publicDeclarationTypes === null
102026
102026
  ? tupleTypeOf$1(declarations)
102027
102027
  : tupleOfTypes$1(publicDeclarationTypes),
102028
102028
  includeImportTypes ? tupleTypeOf$1(imports) : NONE_TYPE$1,
102029
- tupleTypeOf$1(exports$1),
102029
+ tupleTypeOf$1(exports),
102030
102030
  ]));
102031
102031
  }
102032
102032
  /**
@@ -131162,11 +131162,22 @@ function requireConventions$1 () {
131162
131162
  XMLNS: 'http://www.w3.org/2000/xmlns/',
131163
131163
  });
131164
131164
 
131165
+ //[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
131166
+ //[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
131167
+ //[5] Name ::= NameStartChar (NameChar)*
131168
+ var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;//\u10000-\uEFFFF
131169
+ var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
131170
+ var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');
131171
+ //var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/
131172
+
131165
131173
  conventions$1.assign = assign;
131166
131174
  conventions$1.find = find;
131167
131175
  conventions$1.freeze = freeze;
131168
131176
  conventions$1.MIME_TYPE = MIME_TYPE;
131169
131177
  conventions$1.NAMESPACE = NAMESPACE;
131178
+ conventions$1.nameStartChar = nameStartChar;
131179
+ conventions$1.nameChar = nameChar;
131180
+ conventions$1.tagNamePattern = tagNamePattern;
131170
131181
  return conventions$1;
131171
131182
  }
131172
131183
 
@@ -131179,6 +131190,7 @@ function requireDom$1 () {
131179
131190
 
131180
131191
  var find = conventions.find;
131181
131192
  var NAMESPACE = conventions.NAMESPACE;
131193
+ var tagNamePattern = conventions.tagNamePattern;
131182
131194
 
131183
131195
  /**
131184
131196
  * A prerequisite for `[].filter`, to drop elements that are empty
@@ -131288,14 +131300,14 @@ function requireDom$1 () {
131288
131300
  ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2);
131289
131301
  var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3);
131290
131302
  ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4);
131291
- ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
131303
+ var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
131292
131304
  ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6);
131293
131305
  ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7);
131294
131306
  var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8);
131295
131307
  ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9);
131296
131308
  var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10);
131297
131309
  //level2
131298
- ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
131310
+ var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
131299
131311
  ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12);
131300
131312
  ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13);
131301
131313
  ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14);
@@ -131345,9 +131357,10 @@ function requireDom$1 () {
131345
131357
  item: function(index) {
131346
131358
  return index >= 0 && index < this.length ? this[index] : null;
131347
131359
  },
131348
- toString:function(isHTML,nodeFilter){
131360
+ toString:function(isHTML,nodeFilter,options){
131361
+ var requireWellFormed = !!options && !!options.requireWellFormed;
131349
131362
  for(var buf = [], i = 0;i<this.length;i++){
131350
- serializeToString(this[i],buf,isHTML,nodeFilter);
131363
+ serializeToString(this[i],buf,isHTML,nodeFilter,null,requireWellFormed);
131351
131364
  }
131352
131365
  return buf.join('');
131353
131366
  },
@@ -131409,6 +131422,13 @@ function requireDom$1 () {
131409
131422
  * used for attributes or DocumentType entities
131410
131423
  */
131411
131424
  function NamedNodeMap() {
131425
+ // nodeName -> Attr membership index; lets the parse-time de-duplication in
131426
+ // setNamedItem resolve an existing attribute in O(1) instead of scanning the
131427
+ // list, so building an element with M attributes costs O(M) rather than O(M^2).
131428
+ // The numbered entries and length remain the sole authority for attribute order.
131429
+ // Object.create(null) so an attribute named __proto__ or constructor is an
131430
+ // ordinary key.
131431
+ this._nameIndex = Object.create(null);
131412
131432
  }
131413
131433
  function _findNodeIndex(list,node){
131414
131434
  var i = list.length;
@@ -131417,12 +131437,27 @@ function requireDom$1 () {
131417
131437
  }
131418
131438
  }
131419
131439
 
131440
+ function _nnmIndexAdd(list, attr) {
131441
+ list._nameIndex[attr.nodeName] = attr;
131442
+ }
131443
+ function _nnmIndexRemove(list, attr) {
131444
+ // Only drop the entry if it still points at this attribute; a replacement with
131445
+ // a different nodeName may already have re-keyed it.
131446
+ if (list._nameIndex[attr.nodeName] === attr) {
131447
+ delete list._nameIndex[attr.nodeName];
131448
+ }
131449
+ }
131450
+
131420
131451
  function _addNamedNode(el,list,newAttr,oldAttr){
131421
131452
  if(oldAttr){
131422
131453
  list[_findNodeIndex(list,oldAttr)] = newAttr;
131454
+ // oldAttr leaves the list; drop its index entry (its nodeName may differ
131455
+ // from newAttr's when the replacement came via setNamedItemNS).
131456
+ _nnmIndexRemove(list, oldAttr);
131423
131457
  }else {
131424
131458
  list[list.length++] = newAttr;
131425
131459
  }
131460
+ _nnmIndexAdd(list, newAttr);
131426
131461
  if(el){
131427
131462
  newAttr.ownerElement = el;
131428
131463
  var doc = el.ownerDocument;
@@ -131441,6 +131476,7 @@ function requireDom$1 () {
131441
131476
  list[i] = list[++i];
131442
131477
  }
131443
131478
  list.length = lastIndex;
131479
+ _nnmIndexRemove(list, attr);
131444
131480
  if(el){
131445
131481
  var doc = el.ownerDocument;
131446
131482
  if(doc){
@@ -131474,7 +131510,11 @@ function requireDom$1 () {
131474
131510
  if(el && el!=this._ownerElement){
131475
131511
  throw new DOMException(INUSE_ATTRIBUTE_ERR);
131476
131512
  }
131477
- var oldAttr = this.getNamedItem(attr.nodeName);
131513
+ // Resolve any existing attribute with the same nodeName through the O(1)
131514
+ // membership index rather than an O(M) scan — this is the parse-dedup hot
131515
+ // path (setAttributeNode per attribute during parse). Absent -> undefined,
131516
+ // matching getNamedItem's contract.
131517
+ var oldAttr = this._nameIndex[attr.nodeName];
131478
131518
  _addNamedNode(this._ownerElement,this,attr,oldAttr);
131479
131519
  return oldAttr;
131480
131520
  },
@@ -131592,13 +131632,28 @@ function requireDom$1 () {
131592
131632
  /**
131593
131633
  * Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.
131594
131634
  *
131595
- * __This behavior is slightly different from the in the specs__:
131635
+ * __This implementation differs from the specification:__
131596
131636
  * - this implementation is not validating names or qualified names
131597
131637
  * (when parsing XML strings, the SAX parser takes care of that)
131598
131638
  *
131639
+ * Note: `internalSubset` can only be introduced via a direct property write to `node.internalSubset` after creation.
131640
+ * Creation-time validation of `publicId`, `systemId` is not enforced.
131641
+ * The serializer-level check covers all mutation vectors, including direct property writes.
131642
+ * `internalSubset` is only serialized as `[ ... ]` when both `publicId` and `systemId` are
131643
+ * absent (empty or `'.'`) — if either external identifier is present, `internalSubset` is
131644
+ * silently omitted from the serialized output.
131645
+ *
131599
131646
  * @param {string} qualifiedName
131600
131647
  * @param {string} [publicId]
131648
+ * The external subset public identifier. Stored verbatim including surrounding quotes.
131649
+ * When serialized with `requireWellFormed: true` (via the 4th-parameter options object),
131650
+ * throws `DOMException` with code `INVALID_STATE_ERR` if the value is non-empty and does
131651
+ * not match the XML `PubidLiteral` production (W3C DOM Parsing §3.2.1.3; XML 1.0 [12]).
131601
131652
  * @param {string} [systemId]
131653
+ * The external subset system identifier. Stored verbatim including surrounding quotes.
131654
+ * When serialized with `requireWellFormed: true`, throws `DOMException` with code
131655
+ * `INVALID_STATE_ERR` if the value is non-empty and does not match the XML `SystemLiteral`
131656
+ * production (W3C DOM Parsing §3.2.1.3; XML 1.0 [11]).
131602
131657
  * @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation
131603
131658
  * or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`
131604
131659
  *
@@ -131664,18 +131719,73 @@ function requireDom$1 () {
131664
131719
  return cloneNode(this.ownerDocument||this,this,deep);
131665
131720
  },
131666
131721
  // Modified in DOM Level 2:
131667
- normalize:function(){
131668
- var child = this.firstChild;
131669
- while(child){
131670
- var next = child.nextSibling;
131671
- if(next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE){
131672
- this.removeChild(next);
131673
- child.appendData(next.data);
131674
- }else {
131675
- child.normalize();
131676
- child = next;
131677
- }
131678
- }
131722
+ /**
131723
+ * Puts the specified node and all of its subtree into a "normalized" form. In a normalized
131724
+ * subtree, no text nodes in the subtree are empty and there are no adjacent text nodes.
131725
+ *
131726
+ * Specifically, this method merges any adjacent text nodes (i.e., nodes for which `nodeType`
131727
+ * is `TEXT_NODE`) into a single node with the combined data. It also removes any empty text
131728
+ * nodes.
131729
+ *
131730
+ * This method iteratively traverses all child nodes to normalize all descendant nodes within
131731
+ * the subtree.
131732
+ *
131733
+ * @throws {DOMException}
131734
+ * May throw a DOMException if operations within removeChild or appendData (which are
131735
+ * potentially invoked in this method) do not meet their specific constraints.
131736
+ * @see {@link Node.removeChild}
131737
+ * @see {@link CharacterData.appendData}
131738
+ * @see ../docs/walk-dom.md.
131739
+ */
131740
+ normalize: function () {
131741
+ walkDOM(this, null, {
131742
+ enter: function (node) {
131743
+ // Merge adjacent text children of node before walkDOM schedules them.
131744
+ // walkDOM reads lastChild/previousSibling after enter returns, so the
131745
+ // surviving post-merge children are what it descends into.
131746
+ var child = node.firstChild;
131747
+ while (child) {
131748
+ var next = child.nextSibling;
131749
+ if (next !== null && next.nodeType === TEXT_NODE && child.nodeType === TEXT_NODE) {
131750
+ // Merge the whole run of adjacent text nodes at once: gather the
131751
+ // following text siblings' data, unlink them in a single pass, and
131752
+ // re-index the child list a single time. Per-sibling `removeChild`
131753
+ // (each an O(K) re-index) plus per-sibling `appendData` (each an O(K)
131754
+ // string rebuild) is O(K^2) over a long run of single-character text
131755
+ // nodes; this keeps it O(K). The first text node of the run survives
131756
+ // and carries the concatenated data, preserving node identity and
131757
+ // locator semantics.
131758
+ var tail = [];
131759
+ var sibling = next;
131760
+ while (sibling !== null && sibling.nodeType === TEXT_NODE) {
131761
+ tail.push(sibling.data);
131762
+ sibling = sibling.nextSibling;
131763
+ }
131764
+ // `sibling` is now the first non-text node after the run, or null.
131765
+ var removed = child.nextSibling;
131766
+ while (removed !== sibling) {
131767
+ var following = removed.nextSibling;
131768
+ removed.parentNode = null;
131769
+ removed.previousSibling = null;
131770
+ removed.nextSibling = null;
131771
+ removed = following;
131772
+ }
131773
+ child.nextSibling = sibling;
131774
+ if (sibling !== null) {
131775
+ sibling.previousSibling = child;
131776
+ } else {
131777
+ node.lastChild = child;
131778
+ }
131779
+ child.appendData(tail.join('')); // single O(K) string rebuild
131780
+ _onUpdateChild(node.ownerDocument, node); // single O(K) re-index
131781
+ child = sibling;
131782
+ } else {
131783
+ child = next;
131784
+ }
131785
+ }
131786
+ return true; // descend into surviving children
131787
+ },
131788
+ });
131679
131789
  },
131680
131790
  // Introduced in DOM Level 2:
131681
131791
  isSupported:function(feature, version){
@@ -131751,21 +131861,103 @@ function requireDom$1 () {
131751
131861
  copy(NodeType,Node.prototype);
131752
131862
 
131753
131863
  /**
131754
- * @param callback return true for continue,false for break
131755
- * @return boolean true: break visit;
131864
+ * @param {Node} node
131865
+ * Root of the subtree to visit.
131866
+ * @param {function(Node): boolean} callback
131867
+ * Called for each node in depth-first pre-order. Return a truthy value to stop traversal early.
131868
+ * @return {boolean} `true` if traversal was aborted by the callback, `false` otherwise.
131756
131869
  */
131757
- function _visitNode(node,callback){
131758
- if(callback(node)){
131759
- return true;
131760
- }
131761
- if(node = node.firstChild){
131762
- do{
131763
- if(_visitNode(node,callback)){return true}
131764
- }while(node=node.nextSibling)
131765
- }
131870
+ function _visitNode(node, callback) {
131871
+ return walkDOM(node, null, { enter: function (n) { return callback(n) ? walkDOM.STOP : true; } }) === walkDOM.STOP;
131766
131872
  }
131767
131873
 
131874
+ /**
131875
+ * Depth-first pre/post-order DOM tree walker.
131876
+ *
131877
+ * Visits every node in the subtree rooted at `node`. For each node:
131878
+ *
131879
+ * 1. Calls `callbacks.enter(node, context)` before descending into the node's children. The
131880
+ * return value becomes the `context` passed to each child's `enter` call and to the matching
131881
+ * `exit` call.
131882
+ * 2. If `enter` returns `null` or `undefined`, the node's children are skipped;
131883
+ * sibling traversal continues normally.
131884
+ * 3. If `enter` returns `walkDOM.STOP`, the entire traversal is aborted immediately — no
131885
+ * further `enter` or `exit` calls are made.
131886
+ * 4. `lastChild` and `previousSibling` are read **after** `enter` returns, so `enter` may
131887
+ * safely modify the node's own child list before the walker descends. Modifying siblings of
131888
+ * the current node or any other part of the tree produces unpredictable results: nodes already
131889
+ * queued on the stack are visited regardless of DOM changes, and newly inserted nodes outside
131890
+ * the current child list are never visited.
131891
+ * 5. Calls `callbacks.exit(node, context)` (if provided) after all of a node's children have
131892
+ * been visited, passing the same `context` that `enter`
131893
+ * returned for that node.
131894
+ *
131895
+ * This implementation uses an explicit stack and does not recurse — it is safe on arbitrarily
131896
+ * deep trees.
131897
+ *
131898
+ * @param {Node} node
131899
+ * Root of the subtree to walk.
131900
+ * @param {*} context
131901
+ * Initial context value passed to the root node's `enter`.
131902
+ * @param {{ enter: function(Node, *): *, exit?: function(Node, *): void }} callbacks
131903
+ * @returns {void | walkDOM.STOP}
131904
+ * @see ../docs/walk-dom.md.
131905
+ */
131906
+ function walkDOM(node, context, callbacks) {
131907
+ // Each stack frame is {node, context, phase}:
131908
+ // walkDOM.ENTER — call enter, then push children
131909
+ // walkDOM.EXIT — call exit
131910
+ var stack = [{ node: node, context: context, phase: walkDOM.ENTER }];
131911
+ while (stack.length > 0) {
131912
+ var frame = stack.pop();
131913
+ if (frame.phase === walkDOM.ENTER) {
131914
+ var childContext = callbacks.enter(frame.node, frame.context);
131915
+ if (childContext === walkDOM.STOP) {
131916
+ return walkDOM.STOP;
131917
+ }
131918
+ // Push exit frame before children so it fires after all children are processed (Last In First Out)
131919
+ stack.push({ node: frame.node, context: childContext, phase: walkDOM.EXIT });
131920
+ if (childContext === null || childContext === undefined) {
131921
+ continue; // skip children
131922
+ }
131923
+ // lastChild is read after enter returns, so enter may modify the child list.
131924
+ var child = frame.node.lastChild;
131925
+ // Traverse from lastChild backwards so that pushing onto the stack
131926
+ // naturally yields firstChild on top (processed first).
131927
+ while (child) {
131928
+ stack.push({ node: child, context: childContext, phase: walkDOM.ENTER });
131929
+ child = child.previousSibling;
131930
+ }
131931
+ } else {
131932
+ // frame.phase === walkDOM.EXIT
131933
+ if (callbacks.exit) {
131934
+ callbacks.exit(frame.node, frame.context);
131935
+ }
131936
+ }
131937
+ }
131938
+ }
131768
131939
 
131940
+ /**
131941
+ * Sentinel value returned from a `walkDOM` `enter` callback to abort the entire traversal
131942
+ * immediately.
131943
+ *
131944
+ * @type {symbol}
131945
+ */
131946
+ walkDOM.STOP = Symbol('walkDOM.STOP');
131947
+ /**
131948
+ * Phase constant for a stack frame that has not yet been visited.
131949
+ * The `enter` callback is called and children are scheduled.
131950
+ *
131951
+ * @type {number}
131952
+ */
131953
+ walkDOM.ENTER = 0;
131954
+ /**
131955
+ * Phase constant for a stack frame whose subtree has been fully visited.
131956
+ * The `exit` callback is called.
131957
+ *
131958
+ * @type {number}
131959
+ */
131960
+ walkDOM.EXIT = 1;
131769
131961
 
131770
131962
  function Document(){
131771
131963
  this.ownerDocument = this;
@@ -132369,12 +132561,46 @@ function requireDom$1 () {
132369
132561
  node.appendData(data);
132370
132562
  return node;
132371
132563
  },
132564
+ /**
132565
+ * Returns a new CDATASection node whose data is `data`.
132566
+ *
132567
+ * __This implementation differs from the specification:__
132568
+ * - calling this method on an HTML document does not throw `NotSupportedError`.
132569
+ *
132570
+ * @param {string} data
132571
+ * @returns {CDATASection}
132572
+ * @throws DOMException with code `INVALID_CHARACTER_ERR` if `data` contains `"]]>"`.
132573
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createCDATASection
132574
+ * @see https://dom.spec.whatwg.org/#dom-document-createcdatasection
132575
+ */
132372
132576
  createCDATASection : function(data){
132577
+ if (data.indexOf(']]>') !== -1) {
132578
+ throw new DOMException(INVALID_CHARACTER_ERR, 'data contains "]]>"');
132579
+ }
132373
132580
  var node = new CDATASection();
132374
132581
  node.ownerDocument = this;
132375
132582
  node.appendData(data);
132376
132583
  return node;
132377
132584
  },
132585
+ /**
132586
+ * Returns a ProcessingInstruction node whose target is target and data is data.
132587
+ *
132588
+ * __This implementation differs from the specification:__
132589
+ * - it does not do any input validation on the arguments and doesn't throw "InvalidCharacterError".
132590
+ *
132591
+ * Note: When the resulting document is serialized with `requireWellFormed: true`, the
132592
+ * serializer throws with code `INVALID_STATE_ERR` if `.target` is not a valid XML `NCName`
132593
+ * (a `Name` with no colon) or is an ASCII case-insensitive match for `"xml"`, or if `.data`
132594
+ * contains `?>` (W3C DOM Parsing §3.2.1.7). Without that option the target and data are
132595
+ * emitted verbatim.
132596
+ *
132597
+ * @param {string} target
132598
+ * @param {string} data
132599
+ * @returns {ProcessingInstruction}
132600
+ * @see https://developer.mozilla.org/docs/Web/API/Document/createProcessingInstruction
132601
+ * @see https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
132602
+ * @see https://www.w3.org/TR/DOM-Parsing/#dfn-concept-serialize-xml §3.2.1.7
132603
+ */
132378
132604
  createProcessingInstruction : function(target,data){
132379
132605
  var node = new ProcessingInstruction();
132380
132606
  node.ownerDocument = this;
@@ -132391,7 +132617,27 @@ function requireDom$1 () {
132391
132617
  node.specified = true;
132392
132618
  return node;
132393
132619
  },
132620
+ /**
132621
+ * Creates an EntityReference object, serialized as `&name;`.
132622
+ *
132623
+ * The `name` is validated against the XML `Name` production at creation time; an invalid name
132624
+ * throws a `DOMException` with code `INVALID_CHARACTER_ERR`. When the resulting node is
132625
+ * serialized with `requireWellFormed: true`, the serializer re-validates `nodeName` and throws
132626
+ * a `DOMException` with code `INVALID_STATE_ERR` if a later `nodeName` mutation made it invalid;
132627
+ * without that option the name is emitted verbatim.
132628
+ *
132629
+ * Note: xmldom does not expand entities — the parser resolves entity references inline and never
132630
+ * constructs `EntityReference` nodes, so this method is the only producer.
132631
+ *
132632
+ * @param {string} name The name of the entity to reference.
132633
+ * @returns {EntityReference}
132634
+ * @throws {DOMException} With code `INVALID_CHARACTER_ERR` when `name` is not a valid XML `Name`.
132635
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-392B75AE
132636
+ */
132394
132637
  createEntityReference : function(name){
132638
+ if (!tagNamePattern.test(name)) {
132639
+ throw new DOMException(INVALID_CHARACTER_ERR, 'not a valid xml name "' + name + '"');
132640
+ }
132395
132641
  var node = new EntityReference();
132396
132642
  node.ownerDocument = this;
132397
132643
  node.nodeName = name;
@@ -132600,6 +132846,20 @@ function requireDom$1 () {
132600
132846
  _extends(CDATASection,CharacterData);
132601
132847
 
132602
132848
 
132849
+ /**
132850
+ * Represents a DocumentType node (the `<!DOCTYPE ...>` declaration).
132851
+ *
132852
+ * `name`, `publicId`, `systemId`, and `internalSubset` are plain own-property assignments.
132853
+ * xmldom does not enforce the `readonly` constraint declared by the WHATWG DOM spec —
132854
+ * direct property writes succeed silently. Values are serialized verbatim when
132855
+ * `requireWellFormed` is false (the default). When the serializer is invoked with
132856
+ * `requireWellFormed: true` (via the 4th-parameter options object), it validates each
132857
+ * field — including `name`, which is checked against the XML `Name` production — and throws
132858
+ * `DOMException` with code `INVALID_STATE_ERR` on invalid values.
132859
+ *
132860
+ * @class
132861
+ * @see https://developer.mozilla.org/docs/Web/API/DocumentType MDN
132862
+ */
132603
132863
  function DocumentType() {
132604
132864
  } DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
132605
132865
  _extends(DocumentType,Node);
@@ -132612,6 +132872,20 @@ function requireDom$1 () {
132612
132872
  } Entity.prototype.nodeType = ENTITY_NODE;
132613
132873
  _extends(Entity,Node);
132614
132874
 
132875
+ /**
132876
+ * Represents an EntityReference node, serialized as `&nodeName;`.
132877
+ *
132878
+ * `nodeName` is the referenced entity's name, stored verbatim. When serialized with
132879
+ * `requireWellFormed: true`, the serializer validates `nodeName` against the XML `Name` production
132880
+ * and throws a `DOMException` with code `INVALID_STATE_ERR` if it does not match; without that
132881
+ * option the name is emitted verbatim between `&` and `;`.
132882
+ *
132883
+ * Note: xmldom does not expand entities — the parser resolves entity references inline and never
132884
+ * constructs `EntityReference` nodes, so the only producer is `Document.createEntityReference`.
132885
+ *
132886
+ * @class
132887
+ * @see https://www.w3.org/TR/xml/#NT-Name
132888
+ */
132615
132889
  function EntityReference() {
132616
132890
  } EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
132617
132891
  _extends(EntityReference,Node);
@@ -132627,11 +132901,54 @@ function requireDom$1 () {
132627
132901
  ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
132628
132902
  _extends(ProcessingInstruction,Node);
132629
132903
  function XMLSerializer(){}
132630
- XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter){
132631
- return nodeSerializeToString.call(node,isHtml,nodeFilter);
132904
+ /**
132905
+ * Returns the result of serializing `node` to XML.
132906
+ *
132907
+ * When `options.requireWellFormed` is `true`, the serializer throws for content that would
132908
+ * produce ill-formed XML.
132909
+ *
132910
+ * __This implementation differs from the specification:__
132911
+ * - CDATASection nodes whose data contains `]]>` are serialized by splitting the section
132912
+ * at each `]]>` occurrence (following W3C DOM Level 3 Core `split-cdata-sections`
132913
+ * default behaviour) unless `requireWellFormed` is `true`.
132914
+ * - when `requireWellFormed` is `true`, `DOMException` with code `INVALID_STATE_ERR`
132915
+ * is only thrown to prevent injection vectors, not for all the spec mandated checks.
132916
+ *
132917
+ * @param {Node} node
132918
+ * @param {boolean} [isHtml]
132919
+ * @param {function} [nodeFilter]
132920
+ * @param {Object} [options]
132921
+ * @param {boolean} [options.requireWellFormed=false]
132922
+ * When `true`, throws for content that would produce ill-formed XML.
132923
+ * @returns {string}
132924
+ * @throws {DOMException}
132925
+ * With code `INVALID_STATE_ERR` when `requireWellFormed` is `true` and:
132926
+ * - an Element's qualified name (including any namespace prefix) is not a valid XML QName,
132927
+ * - an attribute's qualified name (including a synthesized `xmlns:` namespace declaration) is
132928
+ * not a valid XML QName,
132929
+ * - a CDATASection node's data contains `"]]>"`,
132930
+ * - a Comment node's data contains `"-->"` (bare `"--"` does not throw on this branch),
132931
+ * - a ProcessingInstruction's target is not a valid XML `NCName` (a `Name` with no colon) or is
132932
+ * an ASCII case-insensitive match for `"xml"`, or its data contains `"?>"`,
132933
+ * - a DocumentType's `name` is not a valid XML `Name` (XML 1.0 production [5]),
132934
+ * - a DocumentType's `publicId` is non-empty and does not match the XML `PubidLiteral`
132935
+ * production,
132936
+ * - a DocumentType's `systemId` is non-empty and does not match the XML `SystemLiteral`
132937
+ * production,
132938
+ * - a DocumentType's `internalSubset` contains `"]>"`, or
132939
+ * - an EntityReference's `nodeName` is not a valid XML `Name` (XML 1.0 production [5]).
132940
+ * Note: xmldom does not enforce `readonly` on DocumentType fields — direct property
132941
+ * writes succeed and are covered by the serializer-level checks above.
132942
+ * @see https://html.spec.whatwg.org/#dom-xmlserializer-serializetostring
132943
+ * @see https://w3c.github.io/DOM-Parsing/#xml-serialization
132944
+ * @see https://github.com/w3c/DOM-Parsing/issues/84
132945
+ */
132946
+ XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter,options){
132947
+ return nodeSerializeToString.call(node,isHtml,nodeFilter,options);
132632
132948
  };
132633
132949
  Node.prototype.toString = nodeSerializeToString;
132634
- function nodeSerializeToString(isHtml,nodeFilter){
132950
+ function nodeSerializeToString(isHtml,nodeFilter,options){
132951
+ var requireWellFormed = !!options && !!options.requireWellFormed;
132635
132952
  var buf = [];
132636
132953
  var refNode = this.nodeType == 9 && this.documentElement || this;
132637
132954
  var prefix = refNode.prefix;
@@ -132648,7 +132965,7 @@ function requireDom$1 () {
132648
132965
  ];
132649
132966
  }
132650
132967
  }
132651
- serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces);
132968
+ serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces,requireWellFormed);
132652
132969
  //console.log('###',this.nodeType,uri,prefix,buf.join(''))
132653
132970
  return buf.join('');
132654
132971
  }
@@ -132693,275 +133010,350 @@ function requireDom$1 () {
132693
133010
  * @see https://www.w3.org/TR/xml11/#AVNormalize
132694
133011
  * @see https://w3c.github.io/DOM-Parsing/#serializing-an-element-s-attributes
132695
133012
  */
132696
- function addSerializedAttribute(buf, qualifiedName, value) {
133013
+ function addSerializedAttribute(buf, qualifiedName, value, requireWellFormed) {
133014
+ if (requireWellFormed && !tagNamePattern.test(qualifiedName)) {
133015
+ throw new DOMException(INVALID_STATE_ERR, 'The attribute name "' + qualifiedName + '" is not a valid XML QName');
133016
+ }
132697
133017
  buf.push(' ', qualifiedName, '="', value.replace(/[<>&"\t\n\r]/g, _xmlEncoder), '"');
132698
133018
  }
132699
133019
 
132700
- function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
133020
+ function serializeToString(node, buf, isHTML, nodeFilter, visibleNamespaces, requireWellFormed) {
132701
133021
  if (!visibleNamespaces) {
132702
133022
  visibleNamespaces = [];
132703
133023
  }
132704
-
132705
- if(nodeFilter){
132706
- node = nodeFilter(node);
132707
- if(node){
132708
- if(typeof node == 'string'){
132709
- buf.push(node);
132710
- return;
132711
- }
132712
- }else {
132713
- return;
132714
- }
132715
- //buf.sort.apply(attrs, attributeSorter);
132716
- }
132717
-
132718
- switch(node.nodeType){
132719
- case ELEMENT_NODE:
132720
- var attrs = node.attributes;
132721
- var len = attrs.length;
132722
- var child = node.firstChild;
132723
- var nodeName = node.tagName;
132724
-
132725
- isHTML = NAMESPACE.isHTML(node.namespaceURI) || isHTML;
132726
-
132727
- var prefixedNodeName = nodeName;
132728
- if (!isHTML && !node.prefix && node.namespaceURI) {
132729
- var defaultNS;
132730
- // lookup current default ns from `xmlns` attribute
132731
- for (var ai = 0; ai < attrs.length; ai++) {
132732
- if (attrs.item(ai).name === 'xmlns') {
132733
- defaultNS = attrs.item(ai).value;
132734
- break
132735
- }
132736
- }
132737
- if (!defaultNS) {
132738
- // lookup current default ns in visibleNamespaces
132739
- for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
132740
- var namespace = visibleNamespaces[nsi];
132741
- if (namespace.prefix === '' && namespace.namespace === node.namespaceURI) {
132742
- defaultNS = namespace.namespace;
132743
- break
133024
+ walkDOM(node, { ns: visibleNamespaces, isHTML: isHTML }, {
133025
+ enter: function (n, ctx) {
133026
+ var ns = ctx.ns;
133027
+ var html = ctx.isHTML;
133028
+
133029
+ if (nodeFilter) {
133030
+ n = nodeFilter(n);
133031
+ if (n) {
133032
+ if (typeof n == 'string') {
133033
+ buf.push(n);
133034
+ return null;
132744
133035
  }
133036
+ } else {
133037
+ return null;
132745
133038
  }
132746
133039
  }
132747
- if (defaultNS !== node.namespaceURI) {
132748
- for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
132749
- var namespace = visibleNamespaces[nsi];
132750
- if (namespace.namespace === node.namespaceURI) {
132751
- if (namespace.prefix) {
132752
- prefixedNodeName = namespace.prefix + ':' + nodeName;
133040
+
133041
+ switch (n.nodeType) {
133042
+ case ELEMENT_NODE:
133043
+ var attrs = n.attributes;
133044
+ var len = attrs.length;
133045
+ var nodeName = n.tagName;
133046
+
133047
+ html = NAMESPACE.isHTML(n.namespaceURI) || html;
133048
+
133049
+ var prefixedNodeName = nodeName;
133050
+ if (!html && !n.prefix && n.namespaceURI) {
133051
+ var defaultNS;
133052
+ // lookup current default ns from `xmlns` attribute
133053
+ for (var ai = 0; ai < attrs.length; ai++) {
133054
+ if (attrs.item(ai).name === 'xmlns') {
133055
+ defaultNS = attrs.item(ai).value;
133056
+ break;
133057
+ }
133058
+ }
133059
+ if (!defaultNS) {
133060
+ // lookup current default ns in visibleNamespaces
133061
+ for (var nsi = ns.length - 1; nsi >= 0; nsi--) {
133062
+ var nsEntry = ns[nsi];
133063
+ if (nsEntry.prefix === '' && nsEntry.namespace === n.namespaceURI) {
133064
+ defaultNS = nsEntry.namespace;
133065
+ break;
133066
+ }
133067
+ }
133068
+ }
133069
+ if (defaultNS !== n.namespaceURI) {
133070
+ for (var nsi = ns.length - 1; nsi >= 0; nsi--) {
133071
+ var nsEntry = ns[nsi];
133072
+ if (nsEntry.namespace === n.namespaceURI) {
133073
+ if (nsEntry.prefix) {
133074
+ prefixedNodeName = nsEntry.prefix + ':' + nodeName;
133075
+ }
133076
+ break;
133077
+ }
133078
+ }
132753
133079
  }
132754
- break
132755
133080
  }
132756
- }
132757
- }
132758
- }
132759
133081
 
132760
- buf.push('<', prefixedNodeName);
133082
+ if (requireWellFormed && !tagNamePattern.test(prefixedNodeName)) {
133083
+ throw new DOMException(INVALID_STATE_ERR, 'The element name "' + prefixedNodeName + '" is not a valid XML QName');
133084
+ }
133085
+ buf.push('<', prefixedNodeName);
133086
+
133087
+ // Build a fresh namespace snapshot for this element's children.
133088
+ // The slice prevents sibling elements from inheriting each other's declarations.
133089
+ var childNs = ns.slice();
133090
+ for (var i = 0; i < len; i++) {
133091
+ var attr = attrs.item(i);
133092
+ if (attr.prefix == 'xmlns') {
133093
+ childNs.push({ prefix: attr.localName, namespace: attr.value });
133094
+ } else if (attr.nodeName == 'xmlns') {
133095
+ childNs.push({ prefix: '', namespace: attr.value });
133096
+ }
133097
+ }
132761
133098
 
132762
- for(var i=0;i<len;i++){
132763
- // add namespaces for attributes
132764
- var attr = attrs.item(i);
132765
- if (attr.prefix == 'xmlns') {
132766
- visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
132767
- }else if(attr.nodeName == 'xmlns'){
132768
- visibleNamespaces.push({ prefix: '', namespace: attr.value });
132769
- }
132770
- }
133099
+ for (var i = 0; i < len; i++) {
133100
+ var attr = attrs.item(i);
133101
+ if (needNamespaceDefine(attr, html, childNs)) {
133102
+ var attrPrefix = attr.prefix || '';
133103
+ var uri = attr.namespaceURI;
133104
+ addSerializedAttribute(buf, attrPrefix ? 'xmlns:' + attrPrefix : 'xmlns', uri, requireWellFormed);
133105
+ childNs.push({ prefix: attrPrefix, namespace: uri });
133106
+ }
133107
+ // Apply nodeFilter and serialize the attribute.
133108
+ var filteredAttr = nodeFilter ? nodeFilter(attr) : attr;
133109
+ if (filteredAttr) {
133110
+ if (typeof filteredAttr === 'string') {
133111
+ buf.push(filteredAttr);
133112
+ } else {
133113
+ addSerializedAttribute(buf, filteredAttr.name, filteredAttr.value, requireWellFormed);
133114
+ }
133115
+ }
133116
+ }
132771
133117
 
132772
- for(var i=0;i<len;i++){
132773
- var attr = attrs.item(i);
132774
- if (needNamespaceDefine(attr,isHTML, visibleNamespaces)) {
132775
- var prefix = attr.prefix||'';
132776
- var uri = attr.namespaceURI;
132777
- addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : "xmlns", uri);
132778
- visibleNamespaces.push({ prefix: prefix, namespace:uri });
132779
- }
132780
- serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
132781
- }
133118
+ // add namespace for current node
133119
+ if (nodeName === prefixedNodeName && needNamespaceDefine(n, html, childNs)) {
133120
+ var nodePrefix = n.prefix || '';
133121
+ var uri = n.namespaceURI;
133122
+ addSerializedAttribute(buf, nodePrefix ? 'xmlns:' + nodePrefix : 'xmlns', uri, requireWellFormed);
133123
+ childNs.push({ prefix: nodePrefix, namespace: uri });
133124
+ }
132782
133125
 
132783
- // add namespace for current node
132784
- if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {
132785
- var prefix = node.prefix||'';
132786
- var uri = node.namespaceURI;
132787
- addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : "xmlns", uri);
132788
- visibleNamespaces.push({ prefix: prefix, namespace:uri });
132789
- }
133126
+ var child = n.firstChild;
133127
+ if (child || html && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)) {
133128
+ buf.push('>');
133129
+ if (html && /^script$/i.test(nodeName)) {
133130
+ // Inline serialization for <script> children; return null to skip walkDOM descent.
133131
+ while (child) {
133132
+ if (child.data) {
133133
+ buf.push(child.data);
133134
+ } else {
133135
+ serializeToString(child, buf, html, nodeFilter, childNs.slice(), requireWellFormed);
133136
+ }
133137
+ child = child.nextSibling;
133138
+ }
133139
+ buf.push('</', nodeName, '>');
133140
+ return null;
133141
+ }
133142
+ // Return child context; walkDOM descends and exit emits the closing tag.
133143
+ return { ns: childNs, isHTML: html, tag: prefixedNodeName };
133144
+ } else {
133145
+ buf.push('/>');
133146
+ return null;
133147
+ }
132790
133148
 
132791
- if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
132792
- buf.push('>');
132793
- //if is cdata child node
132794
- if(isHTML && /^script$/i.test(nodeName)){
132795
- while(child){
132796
- if(child.data){
132797
- buf.push(child.data);
132798
- }else {
132799
- serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
133149
+ case DOCUMENT_NODE:
133150
+ case DOCUMENT_FRAGMENT_NODE:
133151
+ // Descend into children; exit is a no-op (tag is null).
133152
+ return { ns: ns.slice(), isHTML: html, tag: null };
133153
+
133154
+ case ATTRIBUTE_NODE:
133155
+ addSerializedAttribute(buf, n.name, n.value, requireWellFormed);
133156
+ return null;
133157
+
133158
+ case TEXT_NODE:
133159
+ /**
133160
+ * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
133161
+ * except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section.
133162
+ * If they are needed elsewhere, they must be escaped using either numeric character references or the strings
133163
+ * `&amp;` and `&lt;` respectively.
133164
+ * The right angle bracket (>) may be represented using the string " &gt; ", and must, for compatibility,
133165
+ * be escaped using either `&gt;` or a character reference when it appears in the string `]]>` in content,
133166
+ * when that string is not marking the end of a CDATA section.
133167
+ *
133168
+ * In the content of elements, character data is any string of characters
133169
+ * which does not contain the start-delimiter of any markup
133170
+ * and does not include the CDATA-section-close delimiter, `]]>`.
133171
+ *
133172
+ * @see https://www.w3.org/TR/xml/#NT-CharData
133173
+ * @see https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node
133174
+ */
133175
+ buf.push(n.data.replace(/[<&>]/g, _xmlEncoder));
133176
+ return null;
133177
+
133178
+ case CDATA_SECTION_NODE:
133179
+ if (requireWellFormed && n.data.indexOf(']]>') !== -1) {
133180
+ throw new DOMException(INVALID_STATE_ERR, 'The CDATASection data contains "]]>"');
132800
133181
  }
132801
- child = child.nextSibling;
132802
- }
132803
- }else
132804
- {
132805
- while(child){
132806
- serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
132807
- child = child.nextSibling;
132808
- }
132809
- }
132810
- buf.push('</',prefixedNodeName,'>');
132811
- }else {
132812
- buf.push('/>');
132813
- }
132814
- // remove added visible namespaces
132815
- //visibleNamespaces.length = startVisibleNamespaces;
132816
- return;
132817
- case DOCUMENT_NODE:
132818
- case DOCUMENT_FRAGMENT_NODE:
132819
- var child = node.firstChild;
132820
- while(child){
132821
- serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
132822
- child = child.nextSibling;
132823
- }
132824
- return;
132825
- case ATTRIBUTE_NODE:
132826
- return addSerializedAttribute(buf, node.name, node.value);
132827
- case TEXT_NODE:
132828
- /**
132829
- * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
132830
- * except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section.
132831
- * If they are needed elsewhere, they must be escaped using either numeric character references or the strings
132832
- * `&amp;` and `&lt;` respectively.
132833
- * The right angle bracket (>) may be represented using the string " &gt; ", and must, for compatibility,
132834
- * be escaped using either `&gt;` or a character reference when it appears in the string `]]>` in content,
132835
- * when that string is not marking the end of a CDATA section.
132836
- *
132837
- * In the content of elements, character data is any string of characters
132838
- * which does not contain the start-delimiter of any markup
132839
- * and does not include the CDATA-section-close delimiter, `]]>`.
132840
- *
132841
- * @see https://www.w3.org/TR/xml/#NT-CharData
132842
- * @see https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node
132843
- */
132844
- return buf.push(node.data
132845
- .replace(/[<&>]/g,_xmlEncoder)
132846
- );
132847
- case CDATA_SECTION_NODE:
132848
- return buf.push( '<![CDATA[',node.data,']]>');
132849
- case COMMENT_NODE:
132850
- return buf.push( "<!--",node.data,"-->");
132851
- case DOCUMENT_TYPE_NODE:
132852
- var pubid = node.publicId;
132853
- var sysid = node.systemId;
132854
- buf.push('<!DOCTYPE ',node.name);
132855
- if(pubid){
132856
- buf.push(' PUBLIC ', pubid);
132857
- if (sysid && sysid!='.') {
132858
- buf.push(' ', sysid);
133182
+ buf.push('<![CDATA[', n.data.replace(/]]>/g, ']]]]><![CDATA[>'), ']]>');
133183
+ return null;
133184
+
133185
+ case COMMENT_NODE:
133186
+ if (requireWellFormed && n.data.indexOf('-->') !== -1) {
133187
+ throw new DOMException(INVALID_STATE_ERR, 'The comment node data contains "-->"');
133188
+ }
133189
+ buf.push('<!--', n.data, '-->');
133190
+ return null;
133191
+
133192
+ case DOCUMENT_TYPE_NODE:
133193
+ if (requireWellFormed) {
133194
+ if (!tagNamePattern.test(n.name)) {
133195
+ throw new DOMException(INVALID_STATE_ERR, 'The doctype name "' + n.name + '" is not a valid XML Name');
133196
+ }
133197
+ if (n.publicId && !/^("[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%']*"|'[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%'"]*')$/.test(n.publicId)) {
133198
+ throw new DOMException(INVALID_STATE_ERR, 'DocumentType publicId is not a valid PubidLiteral');
133199
+ }
133200
+ if (n.systemId && !/^("[^"]*"|'[^']*')$/.test(n.systemId)) {
133201
+ throw new DOMException(INVALID_STATE_ERR, 'DocumentType systemId is not a valid SystemLiteral');
133202
+ }
133203
+ if (n.internalSubset && n.internalSubset.indexOf(']>') !== -1) {
133204
+ throw new DOMException(INVALID_STATE_ERR, 'DocumentType internalSubset contains "]>"');
133205
+ }
133206
+ }
133207
+ var pubid = n.publicId;
133208
+ var sysid = n.systemId;
133209
+ buf.push('<!DOCTYPE ', n.name);
133210
+ if (pubid) {
133211
+ buf.push(' PUBLIC ', pubid);
133212
+ if (sysid && sysid != '.') {
133213
+ buf.push(' ', sysid);
133214
+ }
133215
+ buf.push('>');
133216
+ } else if (sysid && sysid != '.') {
133217
+ buf.push(' SYSTEM ', sysid, '>');
133218
+ } else {
133219
+ var sub = n.internalSubset;
133220
+ if (sub) {
133221
+ buf.push(' [', sub, ']');
133222
+ }
133223
+ buf.push('>');
133224
+ }
133225
+ return null;
133226
+
133227
+ case PROCESSING_INSTRUCTION_NODE:
133228
+ if (requireWellFormed) {
133229
+ if (!tagNamePattern.test(n.target) || n.target.indexOf(':') !== -1 || n.target.toLowerCase() === 'xml') {
133230
+ throw new DOMException(
133231
+ INVALID_STATE_ERR,
133232
+ 'The processing instruction target "' + n.target + '" is not a valid XML NCName or is reserved'
133233
+ );
133234
+ }
133235
+ if (n.data.indexOf('?>') !== -1) {
133236
+ throw new DOMException(INVALID_STATE_ERR, 'The ProcessingInstruction data contains "?>"');
133237
+ }
133238
+ }
133239
+ buf.push('<?', n.target, ' ', n.data, '?>');
133240
+ return null;
133241
+
133242
+ case ENTITY_REFERENCE_NODE:
133243
+ if (requireWellFormed && !tagNamePattern.test(n.nodeName)) {
133244
+ throw new DOMException(
133245
+ INVALID_STATE_ERR,
133246
+ 'The entity reference name "' + n.nodeName + '" is not a valid XML Name'
133247
+ );
133248
+ }
133249
+ buf.push('&', n.nodeName, ';');
133250
+ return null;
133251
+
133252
+ //case ENTITY_NODE:
133253
+ //case NOTATION_NODE:
133254
+ default:
133255
+ buf.push('??', n.nodeName);
133256
+ return null;
132859
133257
  }
132860
- buf.push('>');
132861
- }else if(sysid && sysid!='.'){
132862
- buf.push(' SYSTEM ', sysid, '>');
132863
- }else {
132864
- var sub = node.internalSubset;
132865
- if(sub){
132866
- buf.push(" [",sub,"]");
133258
+ },
133259
+ exit: function (n, childCtx) {
133260
+ if (childCtx && childCtx.tag) {
133261
+ buf.push('</', childCtx.tag, '>');
132867
133262
  }
132868
- buf.push(">");
132869
- }
132870
- return;
132871
- case PROCESSING_INSTRUCTION_NODE:
132872
- return buf.push( "<?",node.target," ",node.data,"?>");
132873
- case ENTITY_REFERENCE_NODE:
132874
- return buf.push( '&',node.nodeName,';');
132875
- //case ENTITY_NODE:
132876
- //case NOTATION_NODE:
132877
- default:
132878
- buf.push('??',node.nodeName);
132879
- }
133263
+ },
133264
+ });
132880
133265
  }
132881
- function importNode(doc,node,deep){
132882
- var node2;
132883
- switch (node.nodeType) {
132884
- case ELEMENT_NODE:
132885
- node2 = node.cloneNode(false);
132886
- node2.ownerDocument = doc;
132887
- //var attrs = node2.attributes;
132888
- //var len = attrs.length;
132889
- //for(var i=0;i<len;i++){
132890
- //node2.setAttributeNodeNS(importNode(doc,attrs.item(i),deep));
132891
- //}
132892
- case DOCUMENT_FRAGMENT_NODE:
132893
- break;
132894
- case ATTRIBUTE_NODE:
132895
- deep = true;
132896
- break;
132897
- //case ENTITY_REFERENCE_NODE:
132898
- //case PROCESSING_INSTRUCTION_NODE:
132899
- ////case TEXT_NODE:
132900
- //case CDATA_SECTION_NODE:
132901
- //case COMMENT_NODE:
132902
- // deep = false;
132903
- // break;
132904
- //case DOCUMENT_NODE:
132905
- //case DOCUMENT_TYPE_NODE:
132906
- //cannot be imported.
132907
- //case ENTITY_NODE:
132908
- //case NOTATION_NODE:
132909
- //can not hit in level3
132910
- //default:throw e;
132911
- }
132912
- if(!node2){
132913
- node2 = node.cloneNode(false);//false
132914
- }
132915
- node2.ownerDocument = doc;
132916
- node2.parentNode = null;
132917
- if(deep){
132918
- var child = node.firstChild;
132919
- while(child){
132920
- node2.appendChild(importNode(doc,child,deep));
132921
- child = child.nextSibling;
132922
- }
132923
- }
132924
- return node2;
133266
+ /**
133267
+ * Imports a node from a different document into `doc`, creating a new copy.
133268
+ * Delegates to {@link walkDOM} for traversal. Each node in the subtree is shallow-cloned,
133269
+ * stamped with `doc` as its `ownerDocument`, and detached (`parentNode` set to `null`).
133270
+ * Children are imported recursively when `deep` is `true`; for {@link Attr} nodes `deep` is
133271
+ * always forced to `true`
133272
+ * because an attribute's value lives in a child text node.
133273
+ *
133274
+ * @param {Document} doc
133275
+ * The document that will own the imported node.
133276
+ * @param {Node} node
133277
+ * The node to import.
133278
+ * @param {boolean} deep
133279
+ * If `true`, descendants are imported recursively.
133280
+ * @returns {Node}
133281
+ * The newly imported node, now owned by `doc`.
133282
+ */
133283
+ function importNode(doc, node, deep) {
133284
+ var destRoot;
133285
+ walkDOM(node, null, {
133286
+ enter: function (srcNode, destParent) {
133287
+ // Shallow-clone the node and stamp it into the target document.
133288
+ var destNode = srcNode.cloneNode(false);
133289
+ destNode.ownerDocument = doc;
133290
+ destNode.parentNode = null;
133291
+ // capture as the root of the imported subtree or attach to parent.
133292
+ if (destParent === null) {
133293
+ destRoot = destNode;
133294
+ } else {
133295
+ destParent.appendChild(destNode);
133296
+ }
133297
+ // ATTRIBUTE_NODE must always be imported deeply: its value lives in a child text node.
133298
+ var shouldDeep = srcNode.nodeType === ATTRIBUTE_NODE || deep;
133299
+ return shouldDeep ? destNode : null;
133300
+ },
133301
+ });
133302
+ return destRoot;
132925
133303
  }
132926
133304
  //
132927
133305
  //var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1,
132928
133306
  // attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
132929
- function cloneNode(doc,node,deep){
132930
- var node2 = new node.constructor();
132931
- for (var n in node) {
132932
- if (Object.prototype.hasOwnProperty.call(node, n)) {
132933
- var v = node[n];
132934
- if (typeof v != "object") {
132935
- if (v != node2[n]) {
132936
- node2[n] = v;
133307
+ function cloneNode(doc, node, deep) {
133308
+ var destRoot;
133309
+ walkDOM(node, null, {
133310
+ enter: function (srcNode, destParent) {
133311
+ // 1. Create a blank node of the same type and copy all scalar own properties.
133312
+ var destNode = new srcNode.constructor();
133313
+ for (var n in srcNode) {
133314
+ if (Object.prototype.hasOwnProperty.call(srcNode, n)) {
133315
+ var v = srcNode[n];
133316
+ if (typeof v != 'object') {
133317
+ if (v != destNode[n]) {
133318
+ destNode[n] = v;
133319
+ }
133320
+ }
132937
133321
  }
132938
133322
  }
132939
- }
132940
- }
132941
- if(node.childNodes){
132942
- node2.childNodes = new NodeList();
132943
- }
132944
- node2.ownerDocument = doc;
132945
- switch (node2.nodeType) {
132946
- case ELEMENT_NODE:
132947
- var attrs = node.attributes;
132948
- var attrs2 = node2.attributes = new NamedNodeMap();
132949
- var len = attrs.length;
132950
- attrs2._ownerElement = node2;
132951
- for(var i=0;i<len;i++){
132952
- node2.setAttributeNode(cloneNode(doc,attrs.item(i),true));
132953
- }
132954
- break; case ATTRIBUTE_NODE:
132955
- deep = true;
132956
- }
132957
- if(deep){
132958
- var child = node.firstChild;
132959
- while(child){
132960
- node2.appendChild(cloneNode(doc,child,deep));
132961
- child = child.nextSibling;
132962
- }
132963
- }
132964
- return node2;
133323
+ if (srcNode.childNodes) {
133324
+ destNode.childNodes = new NodeList();
133325
+ }
133326
+ destNode.ownerDocument = doc;
133327
+ // 2. Handle node-type-specific setup.
133328
+ // Attributes are not DOM children, so they are cloned inline here
133329
+ // rather than by walkDOM descent.
133330
+ // ATTRIBUTE_NODE forces deep=true so its own children are walked.
133331
+ var shouldDeep = deep;
133332
+ switch (destNode.nodeType) {
133333
+ case ELEMENT_NODE:
133334
+ var attrs = srcNode.attributes;
133335
+ var attrs2 = (destNode.attributes = new NamedNodeMap());
133336
+ var len = attrs.length;
133337
+ attrs2._ownerElement = destNode;
133338
+ for (var i = 0; i < len; i++) {
133339
+ destNode.setAttributeNode(cloneNode(doc, attrs.item(i), true));
133340
+ }
133341
+ break;
133342
+ case ATTRIBUTE_NODE:
133343
+ shouldDeep = true;
133344
+ }
133345
+ // 3. Attach to parent, or capture as the root of the cloned subtree.
133346
+ if (destParent !== null) {
133347
+ destParent.appendChild(destNode);
133348
+ } else {
133349
+ destRoot = destNode;
133350
+ }
133351
+ // 4. Return destNode as the context for children (causes walkDOM to descend),
133352
+ // or null to skip children (shallow clone).
133353
+ return shouldDeep ? destNode : null;
133354
+ },
133355
+ });
133356
+ return destRoot;
132965
133357
  }
132966
133358
 
132967
133359
  function __set__(object,key,value){
@@ -132977,49 +133369,55 @@ function requireDom$1 () {
132977
133369
  }
132978
133370
  });
132979
133371
 
132980
- Object.defineProperty(Node.prototype,'textContent',{
132981
- get:function(){
132982
- return getTextContent(this);
133372
+ /**
133373
+ * The text content of this node and its descendants.
133374
+ *
133375
+ * Setting `textContent` on an element or document fragment replaces all child nodes with a
133376
+ * single text node; on other nodes it sets `data`, `value`, and `nodeValue` directly.
133377
+ *
133378
+ * @type {string | null}
133379
+ * @see {@link https://dom.spec.whatwg.org/#dom-node-textcontent}
133380
+ */
133381
+ Object.defineProperty(Node.prototype, 'textContent', {
133382
+ get: function () {
133383
+ if (this.nodeType === ELEMENT_NODE || this.nodeType === DOCUMENT_FRAGMENT_NODE) {
133384
+ var buf = [];
133385
+ walkDOM(this, null, {
133386
+ enter: function (n) {
133387
+ if (n.nodeType === ELEMENT_NODE || n.nodeType === DOCUMENT_FRAGMENT_NODE) {
133388
+ return true; // enter children
133389
+ }
133390
+ if (n.nodeType === PROCESSING_INSTRUCTION_NODE || n.nodeType === COMMENT_NODE) {
133391
+ return null; // excluded from text content
133392
+ }
133393
+ buf.push(n.nodeValue);
133394
+ },
133395
+ });
133396
+ return buf.join('');
133397
+ }
133398
+ return this.nodeValue;
132983
133399
  },
132984
133400
 
132985
- set:function(data){
132986
- switch(this.nodeType){
132987
- case ELEMENT_NODE:
132988
- case DOCUMENT_FRAGMENT_NODE:
132989
- while(this.firstChild){
132990
- this.removeChild(this.firstChild);
132991
- }
132992
- if(data || String(data)){
132993
- this.appendChild(this.ownerDocument.createTextNode(data));
132994
- }
132995
- break;
133401
+ set: function (data) {
133402
+ switch (this.nodeType) {
133403
+ case ELEMENT_NODE:
133404
+ case DOCUMENT_FRAGMENT_NODE:
133405
+ while (this.firstChild) {
133406
+ this.removeChild(this.firstChild);
133407
+ }
133408
+ if (data || String(data)) {
133409
+ this.appendChild(this.ownerDocument.createTextNode(data));
133410
+ }
133411
+ break;
132996
133412
 
132997
- default:
132998
- this.data = data;
132999
- this.value = data;
133000
- this.nodeValue = data;
133413
+ default:
133414
+ this.data = data;
133415
+ this.value = data;
133416
+ this.nodeValue = data;
133001
133417
  }
133002
- }
133418
+ },
133003
133419
  });
133004
133420
 
133005
- function getTextContent(node){
133006
- switch(node.nodeType){
133007
- case ELEMENT_NODE:
133008
- case DOCUMENT_FRAGMENT_NODE:
133009
- var buf = [];
133010
- node = node.firstChild;
133011
- while(node){
133012
- if(node.nodeType!==7 && node.nodeType !==8){
133013
- buf.push(getTextContent(node));
133014
- }
133015
- node = node.nextSibling;
133016
- }
133017
- return buf.join('');
133018
- default:
133019
- return node.nodeValue;
133020
- }
133021
- }
133022
-
133023
133421
  __set__ = function(object,key,value){
133024
133422
  //console.log(value)
133025
133423
  object['$$'+key] = value;
@@ -133035,6 +133433,7 @@ function requireDom$1 () {
133035
133433
  dom$1.Element = Element;
133036
133434
  dom$1.Node = Node;
133037
133435
  dom$1.NodeList = NodeList;
133436
+ dom$1.walkDOM = walkDOM;
133038
133437
  dom$1.XMLSerializer = XMLSerializer;
133039
133438
  //}
133040
133439
  return dom$1;
@@ -133049,7 +133448,7 @@ var hasRequiredEntities$1;
133049
133448
  function requireEntities$1 () {
133050
133449
  if (hasRequiredEntities$1) return entities$1;
133051
133450
  hasRequiredEntities$1 = 1;
133052
- (function (exports$1) {
133451
+ (function (exports) {
133053
133452
 
133054
133453
  var freeze = requireConventions$1().freeze;
133055
133454
 
@@ -133060,7 +133459,7 @@ function requireEntities$1 () {
133060
133459
  * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-predefined-ent W3C XML 1.0
133061
133460
  * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML Wikipedia
133062
133461
  */
133063
- exports$1.XML_ENTITIES = freeze({
133462
+ exports.XML_ENTITIES = freeze({
133064
133463
  amp: '&',
133065
133464
  apos: "'",
133066
133465
  gt: '>',
@@ -133082,7 +133481,7 @@ function requireEntities$1 () {
133082
133481
  * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML Wikipedia (HTML)
133083
133482
  * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML Wikpedia (XHTML)
133084
133483
  */
133085
- exports$1.HTML_ENTITIES = freeze({
133484
+ exports.HTML_ENTITIES = freeze({
133086
133485
  Aacute: '\u00C1',
133087
133486
  aacute: '\u00E1',
133088
133487
  Abreve: '\u0102',
@@ -135214,7 +135613,7 @@ function requireEntities$1 () {
135214
135613
  * @deprecated use `HTML_ENTITIES` instead
135215
135614
  * @see HTML_ENTITIES
135216
135615
  */
135217
- exports$1.entityMap = exports$1.HTML_ENTITIES;
135616
+ exports.entityMap = exports.HTML_ENTITIES;
135218
135617
  } (entities$1));
135219
135618
  return entities$1;
135220
135619
  }
@@ -135227,14 +135626,8 @@ function requireSax$1 () {
135227
135626
  if (hasRequiredSax$1) return sax$1;
135228
135627
  hasRequiredSax$1 = 1;
135229
135628
  var NAMESPACE = requireConventions$1().NAMESPACE;
135629
+ var tagNamePattern = requireConventions$1().tagNamePattern;
135230
135630
 
135231
- //[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
135232
- //[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
135233
- //[5] Name ::= NameStartChar (NameChar)*
135234
- var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;//\u10000-\uEFFFF
135235
- var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
135236
- var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');
135237
- //var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/
135238
135631
  //var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')
135239
135632
 
135240
135633
  //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
@@ -135345,7 +135738,13 @@ function requireSax$1 () {
135345
135738
  switch(source.charAt(tagStart+1)){
135346
135739
  case '/':
135347
135740
  var end = source.indexOf('>',tagStart+3);
135348
- var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, '');
135741
+ // Anchored trailing-whitespace trim. The former `/[ \t\n\r]+$/g` backtracked
135742
+ // quadratically on a name shaped `whitespace-run + non-whitespace char`
135743
+ // (an end tag `</ … x>`): from every start position it extended `[ws]+`
135744
+ // to the end and then failed the `$` anchor. This anchored form matches the
135745
+ // whole string once and captures everything up to the last non-whitespace
135746
+ // character, so it trims in linear time with byte-identical output.
135747
+ var tagName = source.substring(tagStart + 2, end).replace(/^([\s\S]*?[^ \t\n\r])?[ \t\n\r]*$/, '$1');
135349
135748
  var config = parseStack.pop();
135350
135749
  if(end<0){
135351
135750
 
@@ -135356,6 +135755,14 @@ function requireSax$1 () {
135356
135755
  tagName = tagName.replace(/[\s<].*/,'');
135357
135756
  errorHandler.error("end tag name: "+tagName+' maybe not complete');
135358
135757
  end = tagStart+1+tagName.length;
135758
+ }else if(/[ \t\n\r]/.test(tagName) && tagNamePattern.test(tagName.split(/[ \t\n\r]/)[0])){
135759
+ // The XML `ETag` production is `'</' Name S? '>'`: only optional whitespace may follow
135760
+ // the `Name`. A valid `Name` followed by whitespace and non-whitespace residue (e.g.
135761
+ // `</a\nbogus>` or `</a bogus>`) is not well-formed, but historically it was silently
135762
+ // accepted (the malformed end tag ignored, the residue dropped, the element left on the
135763
+ // stack). Report it as a recoverable `error` (which a custom errorHandler may escalate to
135764
+ // fatal) while keeping the existing recovery so the parsed DOM stays byte-identical.
135765
+ errorHandler.error('end tag name is followed by whitespace and trailing content: "'+tagName+'"');
135359
135766
  }
135360
135767
  var localNSMap = config.localNSMap;
135361
135768
  var endMatch = config.tagName == tagName;
@@ -135479,6 +135886,15 @@ function requireSax$1 () {
135479
135886
  var s = S_TAG;//status
135480
135887
  while(true){
135481
135888
  var c = source.charAt(p);
135889
+ if (s === S_TAG && c === '<') {
135890
+ // A `<` can never occur inside a tag name. Without this guard the scan runs
135891
+ // on to the next `>` (or EOF) before the tag name is rejected, so a document
135892
+ // with many `<` inside a malformed tag makes each one-character recovery step
135893
+ // re-scan to the distant `>` — O(n^2). Stopping at the `<` keeps each recovery
135894
+ // step bounded. The candidate scanned so far is reported raw, consistent with
135895
+ // the sibling invalid-tag-name throw below.
135896
+ throw new Error('unexpected < in tag name: ' + source.slice(start, p));
135897
+ }
135482
135898
  switch(c){
135483
135899
  case '=':
135484
135900
  if(s === S_ATTR){//attrName
@@ -135671,9 +136087,13 @@ function requireSax$1 () {
135671
136087
  if(nsPrefix !== false){//hack!!
135672
136088
  if(localNSMap == null){
135673
136089
  localNSMap = {};
135674
- //console.log(currentNSMap,0)
135675
- _copy(currentNSMap,currentNSMap={});
135676
- //console.log(currentNSMap,1)
136090
+ // Derive the child scope's namespace map by prototype-chain inheritance
136091
+ // instead of a flat copy: lookups inherit ancestor prefixes transparently,
136092
+ // so a document nesting N scopes retains O(N) map entries rather than
136093
+ // sum(1..N) = O(N^2). localNSMap stays a flat own-only record of the
136094
+ // prefixes declared at THIS element, so own-property enumeration
136095
+ // (endPrefixMapping below) still reports only local declarations.
136096
+ currentNSMap = Object.create(currentNSMap);
135677
136097
  }
135678
136098
  currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
135679
136099
  a.uri = NAMESPACE.XMLNS;
@@ -135825,7 +136245,7 @@ function requireSax$1 () {
135825
136245
  function parseInstruction(source,start,domBuilder){
135826
136246
  var end = source.indexOf('?>',start);
135827
136247
  if(end){
135828
- var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
136248
+ var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)$/);
135829
136249
  if(match){
135830
136250
  match[0].length;
135831
136251
  domBuilder.processingInstruction(match[1], match[2]) ;
@@ -137022,7 +137442,7 @@ var hasRequiredMoment$1;
137022
137442
  function requireMoment$1 () {
137023
137443
  if (hasRequiredMoment$1) return moment$2.exports;
137024
137444
  hasRequiredMoment$1 = 1;
137025
- (function (module, exports$1) {
137445
+ (function (module, exports) {
137026
137446
  (function (global, factory) {
137027
137447
  module.exports = factory() ;
137028
137448
  }(this, (function () {
@@ -142712,7 +143132,7 @@ function requireMomentTimezone$1 () {
142712
143132
  hasRequiredMomentTimezone$1 = 1;
142713
143133
  (function (module) {
142714
143134
  //! moment-timezone.js
142715
- //! version : 0.6.0
143135
+ //! version : 0.6.3
142716
143136
  //! Copyright (c) JS Foundation and other contributors
142717
143137
  //! license : MIT
142718
143138
  //! github.com/moment/moment-timezone
@@ -142738,7 +143158,7 @@ function requireMomentTimezone$1 () {
142738
143158
  // return moment;
142739
143159
  // }
142740
143160
 
142741
- var VERSION = "0.6.0",
143161
+ var VERSION = "0.6.3",
142742
143162
  zones = {},
142743
143163
  links = {},
142744
143164
  countries = {},
@@ -147299,11 +147719,11 @@ const CURRENCY_INFO = {
147299
147719
  }
147300
147720
  };
147301
147721
 
147302
- const $RAF$1 = window.requestAnimationFrame;
147722
+ const $RAF$1$1 = window.requestAnimationFrame;
147303
147723
  const $RAFQueue$1 = [];
147304
147724
  const invokeLater$1 = fn => {
147305
147725
  if (!$RAFQueue$1.length) {
147306
- $RAF$1(() => {
147726
+ $RAF$1$1(() => {
147307
147727
  $RAFQueue$1.forEach(f => f());
147308
147728
  $RAFQueue$1.length = 0;
147309
147729
  });
@@ -147845,220 +148265,70 @@ const getFnForEventExpr$1 = (expr) => {
147845
148265
  return fnExecutor$1(expr, ExpressionType$2.Action);
147846
148266
  };
147847
148267
 
147848
- // Constants
147849
- const WIDGET_ID_REGEX$1 = /^(widget-[^_]+)/;
147850
- const WIDGET_PROPERTY_REGEX$1 = /^widget-[^_]+_(.+)$/;
147851
- const ARRAY_INDEX_PLACEHOLDER$1 = '[$i]';
147852
- const ARRAY_INDEX_ZERO$1 = '[0]';
147853
148268
  const registry$1 = new Map();
147854
148269
  const watchIdGenerator$1 = new IDGenerator$1('watch-id-');
147855
- const FIRST_TIME_WATCH$1 = Object.freeze({});
147856
- /**
147857
- * Extracts widget ID from identifier (e.g., "widget-id23_eventsource" -> "widget-id23")
147858
- */
147859
- const getWidgetId$1 = (identifier) => {
147860
- if (!identifier || typeof identifier !== 'string') {
147861
- return null;
147862
- }
147863
- const match = identifier.match(WIDGET_ID_REGEX$1);
147864
- return match ? match[1] : null;
147865
- };
147866
- /**
147867
- * Extracts property name from identifier (e.g., "widget-id23_eventsource" -> "eventsource")
147868
- */
147869
- const getPropertyName$1 = (identifier) => {
147870
- if (!identifier || typeof identifier !== 'string') {
147871
- return identifier;
147872
- }
147873
- const match = identifier.match(WIDGET_PROPERTY_REGEX$1);
147874
- return match ? match[1] : identifier;
147875
- };
147876
- /**
147877
- * Array consumer wrapper for array-based expressions
147878
- */
148270
+ const FIRST_TIME_WATCH$1 = {};
148271
+ Object.freeze(FIRST_TIME_WATCH$1);
147879
148272
  const arrayConsumer$1 = (listenerFn, restExpr, newVal, oldVal) => {
147880
- if (!isArray$1(newVal)) {
147881
- return;
147882
- }
147883
- let formattedData = newVal.map(datum => findValueOf$1(datum, restExpr));
147884
- // Flatten if result is array of arrays
147885
- if (isArray$1(formattedData[0])) {
147886
- formattedData = flatten$2(formattedData);
148273
+ let data = newVal, formattedData;
148274
+ if (isArray$1(data)) {
148275
+ formattedData = data.map(function (datum) {
148276
+ return findValueOf$1(datum, restExpr);
148277
+ });
148278
+ // If resulting structure is an array of array, flatten it
148279
+ if (isArray$1(formattedData[0])) {
148280
+ formattedData = flatten$2(formattedData);
148281
+ }
148282
+ listenerFn(formattedData, oldVal);
147887
148283
  }
147888
- listenerFn(formattedData, oldVal);
147889
148284
  };
147890
- /**
147891
- * Updates watch info for array expressions
147892
- */
147893
- const getUpdatedWatchInfo$1 = (expr, acceptsArray, listener) => {
147894
- const regex = /\[\$i\]/g;
148285
+ const getUpdatedWatcInfo$1 = (expr, acceptsArray, listener) => {
148286
+ // listener doesn't accept array
148287
+ // replace all `[$i]` with `[0]` and return the expression
148288
+ let regex = /\[\$i\]/g, $I = '[$i]', $0 = '[0]';
147895
148289
  if (!acceptsArray) {
147896
148290
  return {
147897
- expr: expr.replace(regex, ARRAY_INDEX_ZERO$1),
147898
- listener
148291
+ 'expr': expr.replace(regex, $0),
148292
+ 'listener': listener
147899
148293
  };
147900
148294
  }
147901
- const lastIndex = expr.lastIndexOf(ARRAY_INDEX_PLACEHOLDER$1);
147902
- const baseExpr = expr.substring(0, lastIndex).replace(ARRAY_INDEX_PLACEHOLDER$1, ARRAY_INDEX_ZERO$1);
147903
- const restExpr = expr.substring(lastIndex + ARRAY_INDEX_PLACEHOLDER$1.length);
147904
- const arrayConsumerFn = restExpr
147905
- ? arrayConsumer$1.bind(undefined, listener, restExpr)
147906
- : listener;
148295
+ // listener accepts array
148296
+ // replace all except the last `[$i]` with `[0]` and return the expression.
148297
+ var index = expr.lastIndexOf($I), _expr = expr.substr(0, index).replace($I, $0), restExpr = expr.substr(index + 5), arrayConsumerFn = listener;
148298
+ if (restExpr) {
148299
+ arrayConsumerFn = arrayConsumer$1.bind(undefined, listener, restExpr);
148300
+ }
147907
148301
  return {
147908
- expr: baseExpr,
147909
- listener: arrayConsumerFn
148302
+ 'expr': _expr,
148303
+ 'listener': arrayConsumerFn
147910
148304
  };
147911
148305
  };
147912
- /**
147913
- * Determines if an expression is static (doesn't need to be watched)
147914
- */
147915
- const STATIC_EXPRESSION_NAMES$1 = [
147916
- "row.getProperty('investment')",
147917
- "row.getProperty('factsheetLink')",
147918
- "row.getProperty('isRebalanceEligible')"
147919
- ];
147920
- const isStaticExpression$1 = (expr) => {
147921
- if (typeof expr !== 'string') {
147922
- return false;
147923
- }
147924
- const trimmedExpr = expr.trim();
147925
- // Expressions that always evaluate to localization strings
147926
- if (trimmedExpr.includes('appLocale')) {
147927
- return true;
147928
- }
147929
- // Hard-coded static expression names
147930
- if (STATIC_EXPRESSION_NAMES$1.includes(trimmedExpr)) {
147931
- return true;
147932
- }
147933
- return false;
147934
- };
147935
- /**
147936
- * Gets the scope type from the scope object
147937
- */
147938
- const getScopeType$1 = ($scope) => {
147939
- if (!$scope) {
147940
- return null;
147941
- }
147942
- if ($scope.pageName)
147943
- return 'Page';
147944
- if ($scope.prefabName)
147945
- return 'Prefab';
147946
- if ($scope.partialName)
147947
- return 'Partial';
147948
- // Check for App scope
147949
- if ($scope.Variables !== undefined &&
147950
- $scope.Actions !== undefined &&
147951
- !$scope.pageName &&
147952
- !$scope.prefabName &&
147953
- !$scope.partialName) {
147954
- return 'App';
147955
- }
147956
- if ($scope.constructor?.name === 'AppRef') {
147957
- return 'App';
147958
- }
147959
- return null;
147960
- };
147961
- /**
147962
- * Gets scope name based on scope type
147963
- */
147964
- const getScopeName$1 = ($scope, scopeType) => {
147965
- if (!scopeType || !$scope) {
147966
- return null;
147967
- }
147968
- switch (scopeType) {
147969
- case 'Prefab': return $scope.prefabName || null;
147970
- case 'Partial': return $scope.partialName || null;
147971
- case 'Page': return $scope.pageName || null;
147972
- default: return null;
147973
- }
147974
- };
147975
- /**
147976
- * Main watch function
147977
- */
147978
148306
  const $watch$1 = (expr, $scope, $locals, listener, identifier = watchIdGenerator$1.nextUid(), doNotClone = false, config = {}, isMuted) => {
147979
- // Handle array expressions
147980
- if (expr.includes(ARRAY_INDEX_PLACEHOLDER$1)) {
147981
- const watchInfo = getUpdatedWatchInfo$1(expr, config.arrayType || config.isList || false, listener);
148307
+ if (expr.indexOf('[$i]') !== -1) {
148308
+ let watchInfo = getUpdatedWatcInfo$1(expr, config && (config.arrayType || config.isList), listener);
147982
148309
  expr = watchInfo.expr;
147983
148310
  listener = watchInfo.listener;
147984
148311
  }
147985
- // Handle static expressions
147986
- if (isStaticExpression$1(expr)) {
147987
- try {
147988
- const fn = $parseExpr$1(expr);
147989
- const staticValue = fn($scope, $locals);
147990
- listener(staticValue, FIRST_TIME_WATCH$1);
147991
- }
147992
- catch (e) {
147993
- console.warn(`Error evaluating static expression '${expr}':`, e);
147994
- listener(undefined, FIRST_TIME_WATCH$1);
147995
- }
147996
- return () => { }; // No-op unsubscribe
147997
- }
147998
148312
  const fn = $parseExpr$1();
147999
- const scopeType = getScopeType$1($scope);
148000
- const scopeName = getScopeName$1($scope, scopeType);
148001
- const watchInfo = {
148002
- fn: fn.bind(null, $scope, $locals),
148313
+ registry$1.set(identifier, {
148314
+ fn: fn.bind(expr, $scope, $locals),
148003
148315
  listener,
148004
148316
  expr,
148005
148317
  last: FIRST_TIME_WATCH$1,
148006
148318
  doNotClone,
148007
- isMuted,
148008
- scopeType,
148009
- scopeName
148010
- };
148011
- // Store in registry
148012
- const widgetId = getWidgetId$1(identifier);
148013
- if (widgetId) {
148014
- const propertyName = getPropertyName$1(identifier);
148015
- if (!registry$1.has(widgetId)) {
148016
- registry$1.set(widgetId, {});
148017
- }
148018
- const widgetGroup = registry$1.get(widgetId);
148019
- widgetGroup[propertyName] = watchInfo;
148020
- }
148021
- else {
148022
- registry$1.set(identifier, watchInfo);
148023
- }
148319
+ isMuted: isMuted
148320
+ });
148024
148321
  return () => $unwatch$1(identifier);
148025
148322
  };
148026
- /**
148027
- * Unwatches a single identifier
148028
- */
148029
- const $unwatch$1 = (identifier) => {
148030
- const widgetId = getWidgetId$1(identifier);
148031
- if (widgetId) {
148032
- const propertyName = getPropertyName$1(identifier);
148033
- const widgetGroup = registry$1.get(widgetId);
148034
- if (widgetGroup && typeof widgetGroup === 'object' && !widgetGroup.fn) {
148035
- const watchInfo = widgetGroup[propertyName];
148036
- if (watchInfo) {
148037
- delete widgetGroup[propertyName];
148038
- // Clean up empty widget groups
148039
- if (Object.keys(widgetGroup).length === 0) {
148040
- registry$1.delete(widgetId);
148041
- }
148042
- return true;
148043
- }
148044
- }
148045
- }
148046
- // Fallback to direct lookup
148047
- if (registry$1.has(identifier)) {
148048
- registry$1.delete(identifier);
148049
- return true;
148050
- }
148051
- return false;
148052
- };
148323
+ const $unwatch$1 = identifier => registry$1.delete(identifier);
148324
+ window.watchRegistry = registry$1;
148053
148325
  const $appDigest$1 = (() => {
148054
- return (force = false) => {
148326
+ return (force) => {
148055
148327
  {
148056
148328
  return;
148057
148329
  }
148058
148330
  };
148059
148331
  })();
148060
- // Export registry for debugging
148061
- // (window as any).watchRegistry = registry;
148062
148332
 
148063
148333
  var ComponentType$1;
148064
148334
  (function (ComponentType) {
@@ -148114,8 +148384,8 @@ var Operation$1;
148114
148384
  const DataSource$1 = {
148115
148385
  Operation: Operation$1
148116
148386
  };
148117
- let App$1 = class App {
148118
- };
148387
+ class App {
148388
+ }
148119
148389
  let AbstractI18nService$1 = class AbstractI18nService {
148120
148390
  };
148121
148391
 
@@ -148133,7 +148403,6 @@ const REGEX$1 = {
148133
148403
  SUPPORTED_AUDIO_FORMAT: /\.(mp3|ogg|webm|wma|3gp|wav|m4a)$/i,
148134
148404
  SUPPORTED_VIDEO_FORMAT: /\.(mp4|ogg|webm|wmv|mpeg|mpg|avi|mov)$/i,
148135
148405
  VALID_WEB_URL: /^(http[s]?:\/\/)(www\.){0,1}[a-zA-Z0-9=:?\/\.\-]+(\.[a-zA-Z]{2,5}[\.]{0,1})?/,
148136
- VALID_IMAGE_URL: /^(https?|blob|data|file|ftp):/i,
148137
148406
  REPLACE_PATTERN: /\$\{([^\}]+)\}/g,
148138
148407
  DATA_URL: /^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*)\s*$/i,
148139
148408
  ISO_DATE_FORMAT: /(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})(\.\d+)?([+-]\d{2}:?\d{2}|Z)$/
@@ -148356,9 +148625,6 @@ const isVideoFile$1 = (fileName) => {
148356
148625
  const isValidWebURL$1 = (url) => {
148357
148626
  return (REGEX$1.VALID_WEB_URL).test(url);
148358
148627
  };
148359
- const isValidImageUrl$1 = (url) => {
148360
- return (REGEX$1.VALID_IMAGE_URL).test(url?.trim());
148361
- };
148362
148628
  /*This function returns the url to the resource after checking the validity of url*/
148363
148629
  const getResourceURL$1 = (urlString) => {
148364
148630
  return urlString;
@@ -149612,7 +149878,6 @@ var Utils$1 = /*#__PURE__*/Object.freeze({
149612
149878
  isPageable: isPageable$1,
149613
149879
  isSafari: isSafari$1,
149614
149880
  isTablet: isTablet$1,
149615
- isValidImageUrl: isValidImageUrl$1,
149616
149881
  isValidWebURL: isValidWebURL$1,
149617
149882
  isVideoFile: isVideoFile$1,
149618
149883
  loadScript: loadScript$1,
@@ -150847,14 +151112,14 @@ class ToDatePipe extends WmPipe {
150847
151112
  }
150848
151113
  return this.returnFn('', arguments, this.app.Variables);
150849
151114
  }
150850
- constructor(datePipe, i18nService, app, customPipeManager) {
151115
+ constructor(datePipe, i18nService, customPipeManager) {
150851
151116
  super('toDate', customPipeManager);
150852
151117
  this.datePipe = datePipe;
150853
151118
  this.i18nService = i18nService;
150854
- this.app = app;
150855
151119
  this.customPipeManager = customPipeManager;
151120
+ this.app = inject(App);
150856
151121
  }
150857
- static { this.ɵfac = function ToDatePipe_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ToDatePipe)(ɵɵdirectiveInject(DatePipe, 16), ɵɵdirectiveInject(AbstractI18nService$1, 16), ɵɵdirectiveInject(App$1, 16), ɵɵdirectiveInject(CustomPipeManager$1, 16)); }; }
151122
+ static { this.ɵfac = function ToDatePipe_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ToDatePipe)(ɵɵdirectiveInject(DatePipe, 16), ɵɵdirectiveInject(AbstractI18nService$1, 16), ɵɵdirectiveInject(CustomPipeManager$1, 16)); }; }
150858
151123
  static { this.ɵpipe = /*@__PURE__*/ ɵɵdefinePipe({ name: "toDate", type: ToDatePipe, pure: true, standalone: true }); }
150859
151124
  }
150860
151125
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(ToDatePipe, [{
@@ -150863,7 +151128,7 @@ class ToDatePipe extends WmPipe {
150863
151128
  standalone: true,
150864
151129
  name: 'toDate'
150865
151130
  }]
150866
- }], () => [{ type: DatePipe }, { type: AbstractI18nService$1 }, { type: App$1 }, { type: CustomPipeManager$1 }], null); })();
151131
+ }], () => [{ type: DatePipe }, { type: AbstractI18nService$1 }, { type: CustomPipeManager$1 }], null); })();
150867
151132
  class ToNumberPipe {
150868
151133
  transform(data, fracSize) {
150869
151134
  if (fracSize && !String(fracSize).match(/^(\d+)?\.((\d+)(-(\d+))?)?$/)) {
@@ -150951,9 +151216,9 @@ class SuffixPipe {
150951
151216
  * Custom pipe: It is work as interceptor between the user custom pipe function and angular pipe
150952
151217
  */
150953
151218
  class CustomPipe {
150954
- constructor(app, custmeUserPipe) {
150955
- this.app = app;
151219
+ constructor(custmeUserPipe) {
150956
151220
  this.custmeUserPipe = custmeUserPipe;
151221
+ this.app = inject(App);
150957
151222
  }
150958
151223
  transform(data, pipename) {
150959
151224
  let argumentArr = [];
@@ -150973,7 +151238,7 @@ class CustomPipe {
150973
151238
  return data;
150974
151239
  }
150975
151240
  }
150976
- static { this.ɵfac = function CustomPipe_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || CustomPipe)(ɵɵdirectiveInject(App$1, 16), ɵɵdirectiveInject(CustomPipeManager$1, 16)); }; }
151241
+ static { this.ɵfac = function CustomPipe_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || CustomPipe)(ɵɵdirectiveInject(CustomPipeManager$1, 16)); }; }
150977
151242
  static { this.ɵpipe = /*@__PURE__*/ ɵɵdefinePipe({ name: "custom", type: CustomPipe, pure: true, standalone: true }); }
150978
151243
  }
150979
151244
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(CustomPipe, [{
@@ -150982,7 +151247,7 @@ class CustomPipe {
150982
151247
  standalone: true,
150983
151248
  name: 'custom'
150984
151249
  }]
150985
- }], () => [{ type: App$1 }, { type: CustomPipeManager$1 }], null); })();
151250
+ }], () => [{ type: CustomPipeManager$1 }], null); })();
150986
151251
  class TimeFromNowPipe {
150987
151252
  transform(data) {
150988
151253
  let timestamp;
@@ -158849,14 +159114,14 @@ function createNgModuleType(meta) {
158849
159114
  if (meta.kind === R3NgModuleMetadataKind.Local) {
158850
159115
  return new ExpressionType$1(meta.type.value);
158851
159116
  }
158852
- const { type: moduleType, declarations, exports: exports$1, imports, includeImportTypes, publicDeclarationTypes, } = meta;
159117
+ const { type: moduleType, declarations, exports, imports, includeImportTypes, publicDeclarationTypes, } = meta;
158853
159118
  return new ExpressionType$1(importExpr(Identifiers.NgModuleDeclaration, [
158854
159119
  new ExpressionType$1(moduleType.type),
158855
159120
  publicDeclarationTypes === null
158856
159121
  ? tupleTypeOf(declarations)
158857
159122
  : tupleOfTypes(publicDeclarationTypes),
158858
159123
  includeImportTypes ? tupleTypeOf(imports) : NONE_TYPE,
158859
- tupleTypeOf(exports$1),
159124
+ tupleTypeOf(exports),
158860
159125
  ]));
158861
159126
  }
158862
159127
  /**
@@ -187992,11 +188257,22 @@ function requireConventions () {
187992
188257
  XMLNS: 'http://www.w3.org/2000/xmlns/',
187993
188258
  });
187994
188259
 
188260
+ //[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
188261
+ //[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
188262
+ //[5] Name ::= NameStartChar (NameChar)*
188263
+ var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;//\u10000-\uEFFFF
188264
+ var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
188265
+ var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');
188266
+ //var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/
188267
+
187995
188268
  conventions.assign = assign;
187996
188269
  conventions.find = find;
187997
188270
  conventions.freeze = freeze;
187998
188271
  conventions.MIME_TYPE = MIME_TYPE;
187999
188272
  conventions.NAMESPACE = NAMESPACE;
188273
+ conventions.nameStartChar = nameStartChar;
188274
+ conventions.nameChar = nameChar;
188275
+ conventions.tagNamePattern = tagNamePattern;
188000
188276
  return conventions;
188001
188277
  }
188002
188278
 
@@ -188009,6 +188285,7 @@ function requireDom () {
188009
188285
 
188010
188286
  var find = conventions.find;
188011
188287
  var NAMESPACE = conventions.NAMESPACE;
188288
+ var tagNamePattern = conventions.tagNamePattern;
188012
188289
 
188013
188290
  /**
188014
188291
  * A prerequisite for `[].filter`, to drop elements that are empty
@@ -188118,14 +188395,14 @@ function requireDom () {
188118
188395
  ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2);
188119
188396
  var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3);
188120
188397
  ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4);
188121
- ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
188398
+ var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
188122
188399
  ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6);
188123
188400
  ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7);
188124
188401
  var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8);
188125
188402
  ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9);
188126
188403
  var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10);
188127
188404
  //level2
188128
- ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
188405
+ var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
188129
188406
  ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12);
188130
188407
  ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13);
188131
188408
  ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14);
@@ -188175,9 +188452,10 @@ function requireDom () {
188175
188452
  item: function(index) {
188176
188453
  return index >= 0 && index < this.length ? this[index] : null;
188177
188454
  },
188178
- toString:function(isHTML,nodeFilter){
188455
+ toString:function(isHTML,nodeFilter,options){
188456
+ var requireWellFormed = !!options && !!options.requireWellFormed;
188179
188457
  for(var buf = [], i = 0;i<this.length;i++){
188180
- serializeToString(this[i],buf,isHTML,nodeFilter);
188458
+ serializeToString(this[i],buf,isHTML,nodeFilter,null,requireWellFormed);
188181
188459
  }
188182
188460
  return buf.join('');
188183
188461
  },
@@ -188239,6 +188517,13 @@ function requireDom () {
188239
188517
  * used for attributes or DocumentType entities
188240
188518
  */
188241
188519
  function NamedNodeMap() {
188520
+ // nodeName -> Attr membership index; lets the parse-time de-duplication in
188521
+ // setNamedItem resolve an existing attribute in O(1) instead of scanning the
188522
+ // list, so building an element with M attributes costs O(M) rather than O(M^2).
188523
+ // The numbered entries and length remain the sole authority for attribute order.
188524
+ // Object.create(null) so an attribute named __proto__ or constructor is an
188525
+ // ordinary key.
188526
+ this._nameIndex = Object.create(null);
188242
188527
  }
188243
188528
  function _findNodeIndex(list,node){
188244
188529
  var i = list.length;
@@ -188247,12 +188532,27 @@ function requireDom () {
188247
188532
  }
188248
188533
  }
188249
188534
 
188535
+ function _nnmIndexAdd(list, attr) {
188536
+ list._nameIndex[attr.nodeName] = attr;
188537
+ }
188538
+ function _nnmIndexRemove(list, attr) {
188539
+ // Only drop the entry if it still points at this attribute; a replacement with
188540
+ // a different nodeName may already have re-keyed it.
188541
+ if (list._nameIndex[attr.nodeName] === attr) {
188542
+ delete list._nameIndex[attr.nodeName];
188543
+ }
188544
+ }
188545
+
188250
188546
  function _addNamedNode(el,list,newAttr,oldAttr){
188251
188547
  if(oldAttr){
188252
188548
  list[_findNodeIndex(list,oldAttr)] = newAttr;
188549
+ // oldAttr leaves the list; drop its index entry (its nodeName may differ
188550
+ // from newAttr's when the replacement came via setNamedItemNS).
188551
+ _nnmIndexRemove(list, oldAttr);
188253
188552
  }else {
188254
188553
  list[list.length++] = newAttr;
188255
188554
  }
188555
+ _nnmIndexAdd(list, newAttr);
188256
188556
  if(el){
188257
188557
  newAttr.ownerElement = el;
188258
188558
  var doc = el.ownerDocument;
@@ -188271,6 +188571,7 @@ function requireDom () {
188271
188571
  list[i] = list[++i];
188272
188572
  }
188273
188573
  list.length = lastIndex;
188574
+ _nnmIndexRemove(list, attr);
188274
188575
  if(el){
188275
188576
  var doc = el.ownerDocument;
188276
188577
  if(doc){
@@ -188304,7 +188605,11 @@ function requireDom () {
188304
188605
  if(el && el!=this._ownerElement){
188305
188606
  throw new DOMException(INUSE_ATTRIBUTE_ERR);
188306
188607
  }
188307
- var oldAttr = this.getNamedItem(attr.nodeName);
188608
+ // Resolve any existing attribute with the same nodeName through the O(1)
188609
+ // membership index rather than an O(M) scan — this is the parse-dedup hot
188610
+ // path (setAttributeNode per attribute during parse). Absent -> undefined,
188611
+ // matching getNamedItem's contract.
188612
+ var oldAttr = this._nameIndex[attr.nodeName];
188308
188613
  _addNamedNode(this._ownerElement,this,attr,oldAttr);
188309
188614
  return oldAttr;
188310
188615
  },
@@ -188422,13 +188727,28 @@ function requireDom () {
188422
188727
  /**
188423
188728
  * Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.
188424
188729
  *
188425
- * __This behavior is slightly different from the in the specs__:
188730
+ * __This implementation differs from the specification:__
188426
188731
  * - this implementation is not validating names or qualified names
188427
188732
  * (when parsing XML strings, the SAX parser takes care of that)
188428
188733
  *
188734
+ * Note: `internalSubset` can only be introduced via a direct property write to `node.internalSubset` after creation.
188735
+ * Creation-time validation of `publicId`, `systemId` is not enforced.
188736
+ * The serializer-level check covers all mutation vectors, including direct property writes.
188737
+ * `internalSubset` is only serialized as `[ ... ]` when both `publicId` and `systemId` are
188738
+ * absent (empty or `'.'`) — if either external identifier is present, `internalSubset` is
188739
+ * silently omitted from the serialized output.
188740
+ *
188429
188741
  * @param {string} qualifiedName
188430
188742
  * @param {string} [publicId]
188743
+ * The external subset public identifier. Stored verbatim including surrounding quotes.
188744
+ * When serialized with `requireWellFormed: true` (via the 4th-parameter options object),
188745
+ * throws `DOMException` with code `INVALID_STATE_ERR` if the value is non-empty and does
188746
+ * not match the XML `PubidLiteral` production (W3C DOM Parsing §3.2.1.3; XML 1.0 [12]).
188431
188747
  * @param {string} [systemId]
188748
+ * The external subset system identifier. Stored verbatim including surrounding quotes.
188749
+ * When serialized with `requireWellFormed: true`, throws `DOMException` with code
188750
+ * `INVALID_STATE_ERR` if the value is non-empty and does not match the XML `SystemLiteral`
188751
+ * production (W3C DOM Parsing §3.2.1.3; XML 1.0 [11]).
188432
188752
  * @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation
188433
188753
  * or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`
188434
188754
  *
@@ -188494,18 +188814,73 @@ function requireDom () {
188494
188814
  return cloneNode(this.ownerDocument||this,this,deep);
188495
188815
  },
188496
188816
  // Modified in DOM Level 2:
188497
- normalize:function(){
188498
- var child = this.firstChild;
188499
- while(child){
188500
- var next = child.nextSibling;
188501
- if(next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE){
188502
- this.removeChild(next);
188503
- child.appendData(next.data);
188504
- }else {
188505
- child.normalize();
188506
- child = next;
188507
- }
188508
- }
188817
+ /**
188818
+ * Puts the specified node and all of its subtree into a "normalized" form. In a normalized
188819
+ * subtree, no text nodes in the subtree are empty and there are no adjacent text nodes.
188820
+ *
188821
+ * Specifically, this method merges any adjacent text nodes (i.e., nodes for which `nodeType`
188822
+ * is `TEXT_NODE`) into a single node with the combined data. It also removes any empty text
188823
+ * nodes.
188824
+ *
188825
+ * This method iteratively traverses all child nodes to normalize all descendant nodes within
188826
+ * the subtree.
188827
+ *
188828
+ * @throws {DOMException}
188829
+ * May throw a DOMException if operations within removeChild or appendData (which are
188830
+ * potentially invoked in this method) do not meet their specific constraints.
188831
+ * @see {@link Node.removeChild}
188832
+ * @see {@link CharacterData.appendData}
188833
+ * @see ../docs/walk-dom.md.
188834
+ */
188835
+ normalize: function () {
188836
+ walkDOM(this, null, {
188837
+ enter: function (node) {
188838
+ // Merge adjacent text children of node before walkDOM schedules them.
188839
+ // walkDOM reads lastChild/previousSibling after enter returns, so the
188840
+ // surviving post-merge children are what it descends into.
188841
+ var child = node.firstChild;
188842
+ while (child) {
188843
+ var next = child.nextSibling;
188844
+ if (next !== null && next.nodeType === TEXT_NODE && child.nodeType === TEXT_NODE) {
188845
+ // Merge the whole run of adjacent text nodes at once: gather the
188846
+ // following text siblings' data, unlink them in a single pass, and
188847
+ // re-index the child list a single time. Per-sibling `removeChild`
188848
+ // (each an O(K) re-index) plus per-sibling `appendData` (each an O(K)
188849
+ // string rebuild) is O(K^2) over a long run of single-character text
188850
+ // nodes; this keeps it O(K). The first text node of the run survives
188851
+ // and carries the concatenated data, preserving node identity and
188852
+ // locator semantics.
188853
+ var tail = [];
188854
+ var sibling = next;
188855
+ while (sibling !== null && sibling.nodeType === TEXT_NODE) {
188856
+ tail.push(sibling.data);
188857
+ sibling = sibling.nextSibling;
188858
+ }
188859
+ // `sibling` is now the first non-text node after the run, or null.
188860
+ var removed = child.nextSibling;
188861
+ while (removed !== sibling) {
188862
+ var following = removed.nextSibling;
188863
+ removed.parentNode = null;
188864
+ removed.previousSibling = null;
188865
+ removed.nextSibling = null;
188866
+ removed = following;
188867
+ }
188868
+ child.nextSibling = sibling;
188869
+ if (sibling !== null) {
188870
+ sibling.previousSibling = child;
188871
+ } else {
188872
+ node.lastChild = child;
188873
+ }
188874
+ child.appendData(tail.join('')); // single O(K) string rebuild
188875
+ _onUpdateChild(node.ownerDocument, node); // single O(K) re-index
188876
+ child = sibling;
188877
+ } else {
188878
+ child = next;
188879
+ }
188880
+ }
188881
+ return true; // descend into surviving children
188882
+ },
188883
+ });
188509
188884
  },
188510
188885
  // Introduced in DOM Level 2:
188511
188886
  isSupported:function(feature, version){
@@ -188581,21 +188956,103 @@ function requireDom () {
188581
188956
  copy(NodeType,Node.prototype);
188582
188957
 
188583
188958
  /**
188584
- * @param callback return true for continue,false for break
188585
- * @return boolean true: break visit;
188959
+ * @param {Node} node
188960
+ * Root of the subtree to visit.
188961
+ * @param {function(Node): boolean} callback
188962
+ * Called for each node in depth-first pre-order. Return a truthy value to stop traversal early.
188963
+ * @return {boolean} `true` if traversal was aborted by the callback, `false` otherwise.
188586
188964
  */
188587
- function _visitNode(node,callback){
188588
- if(callback(node)){
188589
- return true;
188590
- }
188591
- if(node = node.firstChild){
188592
- do{
188593
- if(_visitNode(node,callback)){return true}
188594
- }while(node=node.nextSibling)
188595
- }
188965
+ function _visitNode(node, callback) {
188966
+ return walkDOM(node, null, { enter: function (n) { return callback(n) ? walkDOM.STOP : true; } }) === walkDOM.STOP;
188596
188967
  }
188597
188968
 
188969
+ /**
188970
+ * Depth-first pre/post-order DOM tree walker.
188971
+ *
188972
+ * Visits every node in the subtree rooted at `node`. For each node:
188973
+ *
188974
+ * 1. Calls `callbacks.enter(node, context)` before descending into the node's children. The
188975
+ * return value becomes the `context` passed to each child's `enter` call and to the matching
188976
+ * `exit` call.
188977
+ * 2. If `enter` returns `null` or `undefined`, the node's children are skipped;
188978
+ * sibling traversal continues normally.
188979
+ * 3. If `enter` returns `walkDOM.STOP`, the entire traversal is aborted immediately — no
188980
+ * further `enter` or `exit` calls are made.
188981
+ * 4. `lastChild` and `previousSibling` are read **after** `enter` returns, so `enter` may
188982
+ * safely modify the node's own child list before the walker descends. Modifying siblings of
188983
+ * the current node or any other part of the tree produces unpredictable results: nodes already
188984
+ * queued on the stack are visited regardless of DOM changes, and newly inserted nodes outside
188985
+ * the current child list are never visited.
188986
+ * 5. Calls `callbacks.exit(node, context)` (if provided) after all of a node's children have
188987
+ * been visited, passing the same `context` that `enter`
188988
+ * returned for that node.
188989
+ *
188990
+ * This implementation uses an explicit stack and does not recurse — it is safe on arbitrarily
188991
+ * deep trees.
188992
+ *
188993
+ * @param {Node} node
188994
+ * Root of the subtree to walk.
188995
+ * @param {*} context
188996
+ * Initial context value passed to the root node's `enter`.
188997
+ * @param {{ enter: function(Node, *): *, exit?: function(Node, *): void }} callbacks
188998
+ * @returns {void | walkDOM.STOP}
188999
+ * @see ../docs/walk-dom.md.
189000
+ */
189001
+ function walkDOM(node, context, callbacks) {
189002
+ // Each stack frame is {node, context, phase}:
189003
+ // walkDOM.ENTER — call enter, then push children
189004
+ // walkDOM.EXIT — call exit
189005
+ var stack = [{ node: node, context: context, phase: walkDOM.ENTER }];
189006
+ while (stack.length > 0) {
189007
+ var frame = stack.pop();
189008
+ if (frame.phase === walkDOM.ENTER) {
189009
+ var childContext = callbacks.enter(frame.node, frame.context);
189010
+ if (childContext === walkDOM.STOP) {
189011
+ return walkDOM.STOP;
189012
+ }
189013
+ // Push exit frame before children so it fires after all children are processed (Last In First Out)
189014
+ stack.push({ node: frame.node, context: childContext, phase: walkDOM.EXIT });
189015
+ if (childContext === null || childContext === undefined) {
189016
+ continue; // skip children
189017
+ }
189018
+ // lastChild is read after enter returns, so enter may modify the child list.
189019
+ var child = frame.node.lastChild;
189020
+ // Traverse from lastChild backwards so that pushing onto the stack
189021
+ // naturally yields firstChild on top (processed first).
189022
+ while (child) {
189023
+ stack.push({ node: child, context: childContext, phase: walkDOM.ENTER });
189024
+ child = child.previousSibling;
189025
+ }
189026
+ } else {
189027
+ // frame.phase === walkDOM.EXIT
189028
+ if (callbacks.exit) {
189029
+ callbacks.exit(frame.node, frame.context);
189030
+ }
189031
+ }
189032
+ }
189033
+ }
188598
189034
 
189035
+ /**
189036
+ * Sentinel value returned from a `walkDOM` `enter` callback to abort the entire traversal
189037
+ * immediately.
189038
+ *
189039
+ * @type {symbol}
189040
+ */
189041
+ walkDOM.STOP = Symbol('walkDOM.STOP');
189042
+ /**
189043
+ * Phase constant for a stack frame that has not yet been visited.
189044
+ * The `enter` callback is called and children are scheduled.
189045
+ *
189046
+ * @type {number}
189047
+ */
189048
+ walkDOM.ENTER = 0;
189049
+ /**
189050
+ * Phase constant for a stack frame whose subtree has been fully visited.
189051
+ * The `exit` callback is called.
189052
+ *
189053
+ * @type {number}
189054
+ */
189055
+ walkDOM.EXIT = 1;
188599
189056
 
188600
189057
  function Document(){
188601
189058
  this.ownerDocument = this;
@@ -189199,12 +189656,46 @@ function requireDom () {
189199
189656
  node.appendData(data);
189200
189657
  return node;
189201
189658
  },
189659
+ /**
189660
+ * Returns a new CDATASection node whose data is `data`.
189661
+ *
189662
+ * __This implementation differs from the specification:__
189663
+ * - calling this method on an HTML document does not throw `NotSupportedError`.
189664
+ *
189665
+ * @param {string} data
189666
+ * @returns {CDATASection}
189667
+ * @throws DOMException with code `INVALID_CHARACTER_ERR` if `data` contains `"]]>"`.
189668
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createCDATASection
189669
+ * @see https://dom.spec.whatwg.org/#dom-document-createcdatasection
189670
+ */
189202
189671
  createCDATASection : function(data){
189672
+ if (data.indexOf(']]>') !== -1) {
189673
+ throw new DOMException(INVALID_CHARACTER_ERR, 'data contains "]]>"');
189674
+ }
189203
189675
  var node = new CDATASection();
189204
189676
  node.ownerDocument = this;
189205
189677
  node.appendData(data);
189206
189678
  return node;
189207
189679
  },
189680
+ /**
189681
+ * Returns a ProcessingInstruction node whose target is target and data is data.
189682
+ *
189683
+ * __This implementation differs from the specification:__
189684
+ * - it does not do any input validation on the arguments and doesn't throw "InvalidCharacterError".
189685
+ *
189686
+ * Note: When the resulting document is serialized with `requireWellFormed: true`, the
189687
+ * serializer throws with code `INVALID_STATE_ERR` if `.target` is not a valid XML `NCName`
189688
+ * (a `Name` with no colon) or is an ASCII case-insensitive match for `"xml"`, or if `.data`
189689
+ * contains `?>` (W3C DOM Parsing §3.2.1.7). Without that option the target and data are
189690
+ * emitted verbatim.
189691
+ *
189692
+ * @param {string} target
189693
+ * @param {string} data
189694
+ * @returns {ProcessingInstruction}
189695
+ * @see https://developer.mozilla.org/docs/Web/API/Document/createProcessingInstruction
189696
+ * @see https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
189697
+ * @see https://www.w3.org/TR/DOM-Parsing/#dfn-concept-serialize-xml §3.2.1.7
189698
+ */
189208
189699
  createProcessingInstruction : function(target,data){
189209
189700
  var node = new ProcessingInstruction();
189210
189701
  node.ownerDocument = this;
@@ -189221,7 +189712,27 @@ function requireDom () {
189221
189712
  node.specified = true;
189222
189713
  return node;
189223
189714
  },
189715
+ /**
189716
+ * Creates an EntityReference object, serialized as `&name;`.
189717
+ *
189718
+ * The `name` is validated against the XML `Name` production at creation time; an invalid name
189719
+ * throws a `DOMException` with code `INVALID_CHARACTER_ERR`. When the resulting node is
189720
+ * serialized with `requireWellFormed: true`, the serializer re-validates `nodeName` and throws
189721
+ * a `DOMException` with code `INVALID_STATE_ERR` if a later `nodeName` mutation made it invalid;
189722
+ * without that option the name is emitted verbatim.
189723
+ *
189724
+ * Note: xmldom does not expand entities — the parser resolves entity references inline and never
189725
+ * constructs `EntityReference` nodes, so this method is the only producer.
189726
+ *
189727
+ * @param {string} name The name of the entity to reference.
189728
+ * @returns {EntityReference}
189729
+ * @throws {DOMException} With code `INVALID_CHARACTER_ERR` when `name` is not a valid XML `Name`.
189730
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-392B75AE
189731
+ */
189224
189732
  createEntityReference : function(name){
189733
+ if (!tagNamePattern.test(name)) {
189734
+ throw new DOMException(INVALID_CHARACTER_ERR, 'not a valid xml name "' + name + '"');
189735
+ }
189225
189736
  var node = new EntityReference();
189226
189737
  node.ownerDocument = this;
189227
189738
  node.nodeName = name;
@@ -189430,6 +189941,20 @@ function requireDom () {
189430
189941
  _extends(CDATASection,CharacterData);
189431
189942
 
189432
189943
 
189944
+ /**
189945
+ * Represents a DocumentType node (the `<!DOCTYPE ...>` declaration).
189946
+ *
189947
+ * `name`, `publicId`, `systemId`, and `internalSubset` are plain own-property assignments.
189948
+ * xmldom does not enforce the `readonly` constraint declared by the WHATWG DOM spec —
189949
+ * direct property writes succeed silently. Values are serialized verbatim when
189950
+ * `requireWellFormed` is false (the default). When the serializer is invoked with
189951
+ * `requireWellFormed: true` (via the 4th-parameter options object), it validates each
189952
+ * field — including `name`, which is checked against the XML `Name` production — and throws
189953
+ * `DOMException` with code `INVALID_STATE_ERR` on invalid values.
189954
+ *
189955
+ * @class
189956
+ * @see https://developer.mozilla.org/docs/Web/API/DocumentType MDN
189957
+ */
189433
189958
  function DocumentType() {
189434
189959
  } DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
189435
189960
  _extends(DocumentType,Node);
@@ -189442,6 +189967,20 @@ function requireDom () {
189442
189967
  } Entity.prototype.nodeType = ENTITY_NODE;
189443
189968
  _extends(Entity,Node);
189444
189969
 
189970
+ /**
189971
+ * Represents an EntityReference node, serialized as `&nodeName;`.
189972
+ *
189973
+ * `nodeName` is the referenced entity's name, stored verbatim. When serialized with
189974
+ * `requireWellFormed: true`, the serializer validates `nodeName` against the XML `Name` production
189975
+ * and throws a `DOMException` with code `INVALID_STATE_ERR` if it does not match; without that
189976
+ * option the name is emitted verbatim between `&` and `;`.
189977
+ *
189978
+ * Note: xmldom does not expand entities — the parser resolves entity references inline and never
189979
+ * constructs `EntityReference` nodes, so the only producer is `Document.createEntityReference`.
189980
+ *
189981
+ * @class
189982
+ * @see https://www.w3.org/TR/xml/#NT-Name
189983
+ */
189445
189984
  function EntityReference() {
189446
189985
  } EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
189447
189986
  _extends(EntityReference,Node);
@@ -189457,11 +189996,54 @@ function requireDom () {
189457
189996
  ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
189458
189997
  _extends(ProcessingInstruction,Node);
189459
189998
  function XMLSerializer(){}
189460
- XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter){
189461
- return nodeSerializeToString.call(node,isHtml,nodeFilter);
189999
+ /**
190000
+ * Returns the result of serializing `node` to XML.
190001
+ *
190002
+ * When `options.requireWellFormed` is `true`, the serializer throws for content that would
190003
+ * produce ill-formed XML.
190004
+ *
190005
+ * __This implementation differs from the specification:__
190006
+ * - CDATASection nodes whose data contains `]]>` are serialized by splitting the section
190007
+ * at each `]]>` occurrence (following W3C DOM Level 3 Core `split-cdata-sections`
190008
+ * default behaviour) unless `requireWellFormed` is `true`.
190009
+ * - when `requireWellFormed` is `true`, `DOMException` with code `INVALID_STATE_ERR`
190010
+ * is only thrown to prevent injection vectors, not for all the spec mandated checks.
190011
+ *
190012
+ * @param {Node} node
190013
+ * @param {boolean} [isHtml]
190014
+ * @param {function} [nodeFilter]
190015
+ * @param {Object} [options]
190016
+ * @param {boolean} [options.requireWellFormed=false]
190017
+ * When `true`, throws for content that would produce ill-formed XML.
190018
+ * @returns {string}
190019
+ * @throws {DOMException}
190020
+ * With code `INVALID_STATE_ERR` when `requireWellFormed` is `true` and:
190021
+ * - an Element's qualified name (including any namespace prefix) is not a valid XML QName,
190022
+ * - an attribute's qualified name (including a synthesized `xmlns:` namespace declaration) is
190023
+ * not a valid XML QName,
190024
+ * - a CDATASection node's data contains `"]]>"`,
190025
+ * - a Comment node's data contains `"-->"` (bare `"--"` does not throw on this branch),
190026
+ * - a ProcessingInstruction's target is not a valid XML `NCName` (a `Name` with no colon) or is
190027
+ * an ASCII case-insensitive match for `"xml"`, or its data contains `"?>"`,
190028
+ * - a DocumentType's `name` is not a valid XML `Name` (XML 1.0 production [5]),
190029
+ * - a DocumentType's `publicId` is non-empty and does not match the XML `PubidLiteral`
190030
+ * production,
190031
+ * - a DocumentType's `systemId` is non-empty and does not match the XML `SystemLiteral`
190032
+ * production,
190033
+ * - a DocumentType's `internalSubset` contains `"]>"`, or
190034
+ * - an EntityReference's `nodeName` is not a valid XML `Name` (XML 1.0 production [5]).
190035
+ * Note: xmldom does not enforce `readonly` on DocumentType fields — direct property
190036
+ * writes succeed and are covered by the serializer-level checks above.
190037
+ * @see https://html.spec.whatwg.org/#dom-xmlserializer-serializetostring
190038
+ * @see https://w3c.github.io/DOM-Parsing/#xml-serialization
190039
+ * @see https://github.com/w3c/DOM-Parsing/issues/84
190040
+ */
190041
+ XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter,options){
190042
+ return nodeSerializeToString.call(node,isHtml,nodeFilter,options);
189462
190043
  };
189463
190044
  Node.prototype.toString = nodeSerializeToString;
189464
- function nodeSerializeToString(isHtml,nodeFilter){
190045
+ function nodeSerializeToString(isHtml,nodeFilter,options){
190046
+ var requireWellFormed = !!options && !!options.requireWellFormed;
189465
190047
  var buf = [];
189466
190048
  var refNode = this.nodeType == 9 && this.documentElement || this;
189467
190049
  var prefix = refNode.prefix;
@@ -189478,7 +190060,7 @@ function requireDom () {
189478
190060
  ];
189479
190061
  }
189480
190062
  }
189481
- serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces);
190063
+ serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces,requireWellFormed);
189482
190064
  //console.log('###',this.nodeType,uri,prefix,buf.join(''))
189483
190065
  return buf.join('');
189484
190066
  }
@@ -189523,275 +190105,350 @@ function requireDom () {
189523
190105
  * @see https://www.w3.org/TR/xml11/#AVNormalize
189524
190106
  * @see https://w3c.github.io/DOM-Parsing/#serializing-an-element-s-attributes
189525
190107
  */
189526
- function addSerializedAttribute(buf, qualifiedName, value) {
190108
+ function addSerializedAttribute(buf, qualifiedName, value, requireWellFormed) {
190109
+ if (requireWellFormed && !tagNamePattern.test(qualifiedName)) {
190110
+ throw new DOMException(INVALID_STATE_ERR, 'The attribute name "' + qualifiedName + '" is not a valid XML QName');
190111
+ }
189527
190112
  buf.push(' ', qualifiedName, '="', value.replace(/[<>&"\t\n\r]/g, _xmlEncoder), '"');
189528
190113
  }
189529
190114
 
189530
- function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
190115
+ function serializeToString(node, buf, isHTML, nodeFilter, visibleNamespaces, requireWellFormed) {
189531
190116
  if (!visibleNamespaces) {
189532
190117
  visibleNamespaces = [];
189533
190118
  }
189534
-
189535
- if(nodeFilter){
189536
- node = nodeFilter(node);
189537
- if(node){
189538
- if(typeof node == 'string'){
189539
- buf.push(node);
189540
- return;
189541
- }
189542
- }else {
189543
- return;
189544
- }
189545
- //buf.sort.apply(attrs, attributeSorter);
189546
- }
189547
-
189548
- switch(node.nodeType){
189549
- case ELEMENT_NODE:
189550
- var attrs = node.attributes;
189551
- var len = attrs.length;
189552
- var child = node.firstChild;
189553
- var nodeName = node.tagName;
189554
-
189555
- isHTML = NAMESPACE.isHTML(node.namespaceURI) || isHTML;
189556
-
189557
- var prefixedNodeName = nodeName;
189558
- if (!isHTML && !node.prefix && node.namespaceURI) {
189559
- var defaultNS;
189560
- // lookup current default ns from `xmlns` attribute
189561
- for (var ai = 0; ai < attrs.length; ai++) {
189562
- if (attrs.item(ai).name === 'xmlns') {
189563
- defaultNS = attrs.item(ai).value;
189564
- break
189565
- }
189566
- }
189567
- if (!defaultNS) {
189568
- // lookup current default ns in visibleNamespaces
189569
- for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
189570
- var namespace = visibleNamespaces[nsi];
189571
- if (namespace.prefix === '' && namespace.namespace === node.namespaceURI) {
189572
- defaultNS = namespace.namespace;
189573
- break
190119
+ walkDOM(node, { ns: visibleNamespaces, isHTML: isHTML }, {
190120
+ enter: function (n, ctx) {
190121
+ var ns = ctx.ns;
190122
+ var html = ctx.isHTML;
190123
+
190124
+ if (nodeFilter) {
190125
+ n = nodeFilter(n);
190126
+ if (n) {
190127
+ if (typeof n == 'string') {
190128
+ buf.push(n);
190129
+ return null;
189574
190130
  }
190131
+ } else {
190132
+ return null;
189575
190133
  }
189576
190134
  }
189577
- if (defaultNS !== node.namespaceURI) {
189578
- for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
189579
- var namespace = visibleNamespaces[nsi];
189580
- if (namespace.namespace === node.namespaceURI) {
189581
- if (namespace.prefix) {
189582
- prefixedNodeName = namespace.prefix + ':' + nodeName;
190135
+
190136
+ switch (n.nodeType) {
190137
+ case ELEMENT_NODE:
190138
+ var attrs = n.attributes;
190139
+ var len = attrs.length;
190140
+ var nodeName = n.tagName;
190141
+
190142
+ html = NAMESPACE.isHTML(n.namespaceURI) || html;
190143
+
190144
+ var prefixedNodeName = nodeName;
190145
+ if (!html && !n.prefix && n.namespaceURI) {
190146
+ var defaultNS;
190147
+ // lookup current default ns from `xmlns` attribute
190148
+ for (var ai = 0; ai < attrs.length; ai++) {
190149
+ if (attrs.item(ai).name === 'xmlns') {
190150
+ defaultNS = attrs.item(ai).value;
190151
+ break;
190152
+ }
190153
+ }
190154
+ if (!defaultNS) {
190155
+ // lookup current default ns in visibleNamespaces
190156
+ for (var nsi = ns.length - 1; nsi >= 0; nsi--) {
190157
+ var nsEntry = ns[nsi];
190158
+ if (nsEntry.prefix === '' && nsEntry.namespace === n.namespaceURI) {
190159
+ defaultNS = nsEntry.namespace;
190160
+ break;
190161
+ }
190162
+ }
190163
+ }
190164
+ if (defaultNS !== n.namespaceURI) {
190165
+ for (var nsi = ns.length - 1; nsi >= 0; nsi--) {
190166
+ var nsEntry = ns[nsi];
190167
+ if (nsEntry.namespace === n.namespaceURI) {
190168
+ if (nsEntry.prefix) {
190169
+ prefixedNodeName = nsEntry.prefix + ':' + nodeName;
190170
+ }
190171
+ break;
190172
+ }
190173
+ }
189583
190174
  }
189584
- break
189585
190175
  }
189586
- }
189587
- }
189588
- }
189589
190176
 
189590
- buf.push('<', prefixedNodeName);
190177
+ if (requireWellFormed && !tagNamePattern.test(prefixedNodeName)) {
190178
+ throw new DOMException(INVALID_STATE_ERR, 'The element name "' + prefixedNodeName + '" is not a valid XML QName');
190179
+ }
190180
+ buf.push('<', prefixedNodeName);
190181
+
190182
+ // Build a fresh namespace snapshot for this element's children.
190183
+ // The slice prevents sibling elements from inheriting each other's declarations.
190184
+ var childNs = ns.slice();
190185
+ for (var i = 0; i < len; i++) {
190186
+ var attr = attrs.item(i);
190187
+ if (attr.prefix == 'xmlns') {
190188
+ childNs.push({ prefix: attr.localName, namespace: attr.value });
190189
+ } else if (attr.nodeName == 'xmlns') {
190190
+ childNs.push({ prefix: '', namespace: attr.value });
190191
+ }
190192
+ }
189591
190193
 
189592
- for(var i=0;i<len;i++){
189593
- // add namespaces for attributes
189594
- var attr = attrs.item(i);
189595
- if (attr.prefix == 'xmlns') {
189596
- visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
189597
- }else if(attr.nodeName == 'xmlns'){
189598
- visibleNamespaces.push({ prefix: '', namespace: attr.value });
189599
- }
189600
- }
190194
+ for (var i = 0; i < len; i++) {
190195
+ var attr = attrs.item(i);
190196
+ if (needNamespaceDefine(attr, html, childNs)) {
190197
+ var attrPrefix = attr.prefix || '';
190198
+ var uri = attr.namespaceURI;
190199
+ addSerializedAttribute(buf, attrPrefix ? 'xmlns:' + attrPrefix : 'xmlns', uri, requireWellFormed);
190200
+ childNs.push({ prefix: attrPrefix, namespace: uri });
190201
+ }
190202
+ // Apply nodeFilter and serialize the attribute.
190203
+ var filteredAttr = nodeFilter ? nodeFilter(attr) : attr;
190204
+ if (filteredAttr) {
190205
+ if (typeof filteredAttr === 'string') {
190206
+ buf.push(filteredAttr);
190207
+ } else {
190208
+ addSerializedAttribute(buf, filteredAttr.name, filteredAttr.value, requireWellFormed);
190209
+ }
190210
+ }
190211
+ }
189601
190212
 
189602
- for(var i=0;i<len;i++){
189603
- var attr = attrs.item(i);
189604
- if (needNamespaceDefine(attr,isHTML, visibleNamespaces)) {
189605
- var prefix = attr.prefix||'';
189606
- var uri = attr.namespaceURI;
189607
- addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : "xmlns", uri);
189608
- visibleNamespaces.push({ prefix: prefix, namespace:uri });
189609
- }
189610
- serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
189611
- }
190213
+ // add namespace for current node
190214
+ if (nodeName === prefixedNodeName && needNamespaceDefine(n, html, childNs)) {
190215
+ var nodePrefix = n.prefix || '';
190216
+ var uri = n.namespaceURI;
190217
+ addSerializedAttribute(buf, nodePrefix ? 'xmlns:' + nodePrefix : 'xmlns', uri, requireWellFormed);
190218
+ childNs.push({ prefix: nodePrefix, namespace: uri });
190219
+ }
189612
190220
 
189613
- // add namespace for current node
189614
- if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {
189615
- var prefix = node.prefix||'';
189616
- var uri = node.namespaceURI;
189617
- addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : "xmlns", uri);
189618
- visibleNamespaces.push({ prefix: prefix, namespace:uri });
189619
- }
190221
+ var child = n.firstChild;
190222
+ if (child || html && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)) {
190223
+ buf.push('>');
190224
+ if (html && /^script$/i.test(nodeName)) {
190225
+ // Inline serialization for <script> children; return null to skip walkDOM descent.
190226
+ while (child) {
190227
+ if (child.data) {
190228
+ buf.push(child.data);
190229
+ } else {
190230
+ serializeToString(child, buf, html, nodeFilter, childNs.slice(), requireWellFormed);
190231
+ }
190232
+ child = child.nextSibling;
190233
+ }
190234
+ buf.push('</', nodeName, '>');
190235
+ return null;
190236
+ }
190237
+ // Return child context; walkDOM descends and exit emits the closing tag.
190238
+ return { ns: childNs, isHTML: html, tag: prefixedNodeName };
190239
+ } else {
190240
+ buf.push('/>');
190241
+ return null;
190242
+ }
189620
190243
 
189621
- if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
189622
- buf.push('>');
189623
- //if is cdata child node
189624
- if(isHTML && /^script$/i.test(nodeName)){
189625
- while(child){
189626
- if(child.data){
189627
- buf.push(child.data);
189628
- }else {
189629
- serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
190244
+ case DOCUMENT_NODE:
190245
+ case DOCUMENT_FRAGMENT_NODE:
190246
+ // Descend into children; exit is a no-op (tag is null).
190247
+ return { ns: ns.slice(), isHTML: html, tag: null };
190248
+
190249
+ case ATTRIBUTE_NODE:
190250
+ addSerializedAttribute(buf, n.name, n.value, requireWellFormed);
190251
+ return null;
190252
+
190253
+ case TEXT_NODE:
190254
+ /**
190255
+ * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
190256
+ * except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section.
190257
+ * If they are needed elsewhere, they must be escaped using either numeric character references or the strings
190258
+ * `&amp;` and `&lt;` respectively.
190259
+ * The right angle bracket (>) may be represented using the string " &gt; ", and must, for compatibility,
190260
+ * be escaped using either `&gt;` or a character reference when it appears in the string `]]>` in content,
190261
+ * when that string is not marking the end of a CDATA section.
190262
+ *
190263
+ * In the content of elements, character data is any string of characters
190264
+ * which does not contain the start-delimiter of any markup
190265
+ * and does not include the CDATA-section-close delimiter, `]]>`.
190266
+ *
190267
+ * @see https://www.w3.org/TR/xml/#NT-CharData
190268
+ * @see https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node
190269
+ */
190270
+ buf.push(n.data.replace(/[<&>]/g, _xmlEncoder));
190271
+ return null;
190272
+
190273
+ case CDATA_SECTION_NODE:
190274
+ if (requireWellFormed && n.data.indexOf(']]>') !== -1) {
190275
+ throw new DOMException(INVALID_STATE_ERR, 'The CDATASection data contains "]]>"');
189630
190276
  }
189631
- child = child.nextSibling;
189632
- }
189633
- }else
189634
- {
189635
- while(child){
189636
- serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
189637
- child = child.nextSibling;
189638
- }
189639
- }
189640
- buf.push('</',prefixedNodeName,'>');
189641
- }else {
189642
- buf.push('/>');
189643
- }
189644
- // remove added visible namespaces
189645
- //visibleNamespaces.length = startVisibleNamespaces;
189646
- return;
189647
- case DOCUMENT_NODE:
189648
- case DOCUMENT_FRAGMENT_NODE:
189649
- var child = node.firstChild;
189650
- while(child){
189651
- serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
189652
- child = child.nextSibling;
189653
- }
189654
- return;
189655
- case ATTRIBUTE_NODE:
189656
- return addSerializedAttribute(buf, node.name, node.value);
189657
- case TEXT_NODE:
189658
- /**
189659
- * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
189660
- * except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section.
189661
- * If they are needed elsewhere, they must be escaped using either numeric character references or the strings
189662
- * `&amp;` and `&lt;` respectively.
189663
- * The right angle bracket (>) may be represented using the string " &gt; ", and must, for compatibility,
189664
- * be escaped using either `&gt;` or a character reference when it appears in the string `]]>` in content,
189665
- * when that string is not marking the end of a CDATA section.
189666
- *
189667
- * In the content of elements, character data is any string of characters
189668
- * which does not contain the start-delimiter of any markup
189669
- * and does not include the CDATA-section-close delimiter, `]]>`.
189670
- *
189671
- * @see https://www.w3.org/TR/xml/#NT-CharData
189672
- * @see https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node
189673
- */
189674
- return buf.push(node.data
189675
- .replace(/[<&>]/g,_xmlEncoder)
189676
- );
189677
- case CDATA_SECTION_NODE:
189678
- return buf.push( '<![CDATA[',node.data,']]>');
189679
- case COMMENT_NODE:
189680
- return buf.push( "<!--",node.data,"-->");
189681
- case DOCUMENT_TYPE_NODE:
189682
- var pubid = node.publicId;
189683
- var sysid = node.systemId;
189684
- buf.push('<!DOCTYPE ',node.name);
189685
- if(pubid){
189686
- buf.push(' PUBLIC ', pubid);
189687
- if (sysid && sysid!='.') {
189688
- buf.push(' ', sysid);
190277
+ buf.push('<![CDATA[', n.data.replace(/]]>/g, ']]]]><![CDATA[>'), ']]>');
190278
+ return null;
190279
+
190280
+ case COMMENT_NODE:
190281
+ if (requireWellFormed && n.data.indexOf('-->') !== -1) {
190282
+ throw new DOMException(INVALID_STATE_ERR, 'The comment node data contains "-->"');
190283
+ }
190284
+ buf.push('<!--', n.data, '-->');
190285
+ return null;
190286
+
190287
+ case DOCUMENT_TYPE_NODE:
190288
+ if (requireWellFormed) {
190289
+ if (!tagNamePattern.test(n.name)) {
190290
+ throw new DOMException(INVALID_STATE_ERR, 'The doctype name "' + n.name + '" is not a valid XML Name');
190291
+ }
190292
+ if (n.publicId && !/^("[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%']*"|'[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%'"]*')$/.test(n.publicId)) {
190293
+ throw new DOMException(INVALID_STATE_ERR, 'DocumentType publicId is not a valid PubidLiteral');
190294
+ }
190295
+ if (n.systemId && !/^("[^"]*"|'[^']*')$/.test(n.systemId)) {
190296
+ throw new DOMException(INVALID_STATE_ERR, 'DocumentType systemId is not a valid SystemLiteral');
190297
+ }
190298
+ if (n.internalSubset && n.internalSubset.indexOf(']>') !== -1) {
190299
+ throw new DOMException(INVALID_STATE_ERR, 'DocumentType internalSubset contains "]>"');
190300
+ }
190301
+ }
190302
+ var pubid = n.publicId;
190303
+ var sysid = n.systemId;
190304
+ buf.push('<!DOCTYPE ', n.name);
190305
+ if (pubid) {
190306
+ buf.push(' PUBLIC ', pubid);
190307
+ if (sysid && sysid != '.') {
190308
+ buf.push(' ', sysid);
190309
+ }
190310
+ buf.push('>');
190311
+ } else if (sysid && sysid != '.') {
190312
+ buf.push(' SYSTEM ', sysid, '>');
190313
+ } else {
190314
+ var sub = n.internalSubset;
190315
+ if (sub) {
190316
+ buf.push(' [', sub, ']');
190317
+ }
190318
+ buf.push('>');
190319
+ }
190320
+ return null;
190321
+
190322
+ case PROCESSING_INSTRUCTION_NODE:
190323
+ if (requireWellFormed) {
190324
+ if (!tagNamePattern.test(n.target) || n.target.indexOf(':') !== -1 || n.target.toLowerCase() === 'xml') {
190325
+ throw new DOMException(
190326
+ INVALID_STATE_ERR,
190327
+ 'The processing instruction target "' + n.target + '" is not a valid XML NCName or is reserved'
190328
+ );
190329
+ }
190330
+ if (n.data.indexOf('?>') !== -1) {
190331
+ throw new DOMException(INVALID_STATE_ERR, 'The ProcessingInstruction data contains "?>"');
190332
+ }
190333
+ }
190334
+ buf.push('<?', n.target, ' ', n.data, '?>');
190335
+ return null;
190336
+
190337
+ case ENTITY_REFERENCE_NODE:
190338
+ if (requireWellFormed && !tagNamePattern.test(n.nodeName)) {
190339
+ throw new DOMException(
190340
+ INVALID_STATE_ERR,
190341
+ 'The entity reference name "' + n.nodeName + '" is not a valid XML Name'
190342
+ );
190343
+ }
190344
+ buf.push('&', n.nodeName, ';');
190345
+ return null;
190346
+
190347
+ //case ENTITY_NODE:
190348
+ //case NOTATION_NODE:
190349
+ default:
190350
+ buf.push('??', n.nodeName);
190351
+ return null;
189689
190352
  }
189690
- buf.push('>');
189691
- }else if(sysid && sysid!='.'){
189692
- buf.push(' SYSTEM ', sysid, '>');
189693
- }else {
189694
- var sub = node.internalSubset;
189695
- if(sub){
189696
- buf.push(" [",sub,"]");
190353
+ },
190354
+ exit: function (n, childCtx) {
190355
+ if (childCtx && childCtx.tag) {
190356
+ buf.push('</', childCtx.tag, '>');
189697
190357
  }
189698
- buf.push(">");
189699
- }
189700
- return;
189701
- case PROCESSING_INSTRUCTION_NODE:
189702
- return buf.push( "<?",node.target," ",node.data,"?>");
189703
- case ENTITY_REFERENCE_NODE:
189704
- return buf.push( '&',node.nodeName,';');
189705
- //case ENTITY_NODE:
189706
- //case NOTATION_NODE:
189707
- default:
189708
- buf.push('??',node.nodeName);
189709
- }
190358
+ },
190359
+ });
189710
190360
  }
189711
- function importNode(doc,node,deep){
189712
- var node2;
189713
- switch (node.nodeType) {
189714
- case ELEMENT_NODE:
189715
- node2 = node.cloneNode(false);
189716
- node2.ownerDocument = doc;
189717
- //var attrs = node2.attributes;
189718
- //var len = attrs.length;
189719
- //for(var i=0;i<len;i++){
189720
- //node2.setAttributeNodeNS(importNode(doc,attrs.item(i),deep));
189721
- //}
189722
- case DOCUMENT_FRAGMENT_NODE:
189723
- break;
189724
- case ATTRIBUTE_NODE:
189725
- deep = true;
189726
- break;
189727
- //case ENTITY_REFERENCE_NODE:
189728
- //case PROCESSING_INSTRUCTION_NODE:
189729
- ////case TEXT_NODE:
189730
- //case CDATA_SECTION_NODE:
189731
- //case COMMENT_NODE:
189732
- // deep = false;
189733
- // break;
189734
- //case DOCUMENT_NODE:
189735
- //case DOCUMENT_TYPE_NODE:
189736
- //cannot be imported.
189737
- //case ENTITY_NODE:
189738
- //case NOTATION_NODE:
189739
- //can not hit in level3
189740
- //default:throw e;
189741
- }
189742
- if(!node2){
189743
- node2 = node.cloneNode(false);//false
189744
- }
189745
- node2.ownerDocument = doc;
189746
- node2.parentNode = null;
189747
- if(deep){
189748
- var child = node.firstChild;
189749
- while(child){
189750
- node2.appendChild(importNode(doc,child,deep));
189751
- child = child.nextSibling;
189752
- }
189753
- }
189754
- return node2;
190361
+ /**
190362
+ * Imports a node from a different document into `doc`, creating a new copy.
190363
+ * Delegates to {@link walkDOM} for traversal. Each node in the subtree is shallow-cloned,
190364
+ * stamped with `doc` as its `ownerDocument`, and detached (`parentNode` set to `null`).
190365
+ * Children are imported recursively when `deep` is `true`; for {@link Attr} nodes `deep` is
190366
+ * always forced to `true`
190367
+ * because an attribute's value lives in a child text node.
190368
+ *
190369
+ * @param {Document} doc
190370
+ * The document that will own the imported node.
190371
+ * @param {Node} node
190372
+ * The node to import.
190373
+ * @param {boolean} deep
190374
+ * If `true`, descendants are imported recursively.
190375
+ * @returns {Node}
190376
+ * The newly imported node, now owned by `doc`.
190377
+ */
190378
+ function importNode(doc, node, deep) {
190379
+ var destRoot;
190380
+ walkDOM(node, null, {
190381
+ enter: function (srcNode, destParent) {
190382
+ // Shallow-clone the node and stamp it into the target document.
190383
+ var destNode = srcNode.cloneNode(false);
190384
+ destNode.ownerDocument = doc;
190385
+ destNode.parentNode = null;
190386
+ // capture as the root of the imported subtree or attach to parent.
190387
+ if (destParent === null) {
190388
+ destRoot = destNode;
190389
+ } else {
190390
+ destParent.appendChild(destNode);
190391
+ }
190392
+ // ATTRIBUTE_NODE must always be imported deeply: its value lives in a child text node.
190393
+ var shouldDeep = srcNode.nodeType === ATTRIBUTE_NODE || deep;
190394
+ return shouldDeep ? destNode : null;
190395
+ },
190396
+ });
190397
+ return destRoot;
189755
190398
  }
189756
190399
  //
189757
190400
  //var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1,
189758
190401
  // attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
189759
- function cloneNode(doc,node,deep){
189760
- var node2 = new node.constructor();
189761
- for (var n in node) {
189762
- if (Object.prototype.hasOwnProperty.call(node, n)) {
189763
- var v = node[n];
189764
- if (typeof v != "object") {
189765
- if (v != node2[n]) {
189766
- node2[n] = v;
190402
+ function cloneNode(doc, node, deep) {
190403
+ var destRoot;
190404
+ walkDOM(node, null, {
190405
+ enter: function (srcNode, destParent) {
190406
+ // 1. Create a blank node of the same type and copy all scalar own properties.
190407
+ var destNode = new srcNode.constructor();
190408
+ for (var n in srcNode) {
190409
+ if (Object.prototype.hasOwnProperty.call(srcNode, n)) {
190410
+ var v = srcNode[n];
190411
+ if (typeof v != 'object') {
190412
+ if (v != destNode[n]) {
190413
+ destNode[n] = v;
190414
+ }
190415
+ }
189767
190416
  }
189768
190417
  }
189769
- }
189770
- }
189771
- if(node.childNodes){
189772
- node2.childNodes = new NodeList();
189773
- }
189774
- node2.ownerDocument = doc;
189775
- switch (node2.nodeType) {
189776
- case ELEMENT_NODE:
189777
- var attrs = node.attributes;
189778
- var attrs2 = node2.attributes = new NamedNodeMap();
189779
- var len = attrs.length;
189780
- attrs2._ownerElement = node2;
189781
- for(var i=0;i<len;i++){
189782
- node2.setAttributeNode(cloneNode(doc,attrs.item(i),true));
189783
- }
189784
- break; case ATTRIBUTE_NODE:
189785
- deep = true;
189786
- }
189787
- if(deep){
189788
- var child = node.firstChild;
189789
- while(child){
189790
- node2.appendChild(cloneNode(doc,child,deep));
189791
- child = child.nextSibling;
189792
- }
189793
- }
189794
- return node2;
190418
+ if (srcNode.childNodes) {
190419
+ destNode.childNodes = new NodeList();
190420
+ }
190421
+ destNode.ownerDocument = doc;
190422
+ // 2. Handle node-type-specific setup.
190423
+ // Attributes are not DOM children, so they are cloned inline here
190424
+ // rather than by walkDOM descent.
190425
+ // ATTRIBUTE_NODE forces deep=true so its own children are walked.
190426
+ var shouldDeep = deep;
190427
+ switch (destNode.nodeType) {
190428
+ case ELEMENT_NODE:
190429
+ var attrs = srcNode.attributes;
190430
+ var attrs2 = (destNode.attributes = new NamedNodeMap());
190431
+ var len = attrs.length;
190432
+ attrs2._ownerElement = destNode;
190433
+ for (var i = 0; i < len; i++) {
190434
+ destNode.setAttributeNode(cloneNode(doc, attrs.item(i), true));
190435
+ }
190436
+ break;
190437
+ case ATTRIBUTE_NODE:
190438
+ shouldDeep = true;
190439
+ }
190440
+ // 3. Attach to parent, or capture as the root of the cloned subtree.
190441
+ if (destParent !== null) {
190442
+ destParent.appendChild(destNode);
190443
+ } else {
190444
+ destRoot = destNode;
190445
+ }
190446
+ // 4. Return destNode as the context for children (causes walkDOM to descend),
190447
+ // or null to skip children (shallow clone).
190448
+ return shouldDeep ? destNode : null;
190449
+ },
190450
+ });
190451
+ return destRoot;
189795
190452
  }
189796
190453
 
189797
190454
  function __set__(object,key,value){
@@ -189807,49 +190464,55 @@ function requireDom () {
189807
190464
  }
189808
190465
  });
189809
190466
 
189810
- Object.defineProperty(Node.prototype,'textContent',{
189811
- get:function(){
189812
- return getTextContent(this);
190467
+ /**
190468
+ * The text content of this node and its descendants.
190469
+ *
190470
+ * Setting `textContent` on an element or document fragment replaces all child nodes with a
190471
+ * single text node; on other nodes it sets `data`, `value`, and `nodeValue` directly.
190472
+ *
190473
+ * @type {string | null}
190474
+ * @see {@link https://dom.spec.whatwg.org/#dom-node-textcontent}
190475
+ */
190476
+ Object.defineProperty(Node.prototype, 'textContent', {
190477
+ get: function () {
190478
+ if (this.nodeType === ELEMENT_NODE || this.nodeType === DOCUMENT_FRAGMENT_NODE) {
190479
+ var buf = [];
190480
+ walkDOM(this, null, {
190481
+ enter: function (n) {
190482
+ if (n.nodeType === ELEMENT_NODE || n.nodeType === DOCUMENT_FRAGMENT_NODE) {
190483
+ return true; // enter children
190484
+ }
190485
+ if (n.nodeType === PROCESSING_INSTRUCTION_NODE || n.nodeType === COMMENT_NODE) {
190486
+ return null; // excluded from text content
190487
+ }
190488
+ buf.push(n.nodeValue);
190489
+ },
190490
+ });
190491
+ return buf.join('');
190492
+ }
190493
+ return this.nodeValue;
189813
190494
  },
189814
190495
 
189815
- set:function(data){
189816
- switch(this.nodeType){
189817
- case ELEMENT_NODE:
189818
- case DOCUMENT_FRAGMENT_NODE:
189819
- while(this.firstChild){
189820
- this.removeChild(this.firstChild);
189821
- }
189822
- if(data || String(data)){
189823
- this.appendChild(this.ownerDocument.createTextNode(data));
189824
- }
189825
- break;
190496
+ set: function (data) {
190497
+ switch (this.nodeType) {
190498
+ case ELEMENT_NODE:
190499
+ case DOCUMENT_FRAGMENT_NODE:
190500
+ while (this.firstChild) {
190501
+ this.removeChild(this.firstChild);
190502
+ }
190503
+ if (data || String(data)) {
190504
+ this.appendChild(this.ownerDocument.createTextNode(data));
190505
+ }
190506
+ break;
189826
190507
 
189827
- default:
189828
- this.data = data;
189829
- this.value = data;
189830
- this.nodeValue = data;
190508
+ default:
190509
+ this.data = data;
190510
+ this.value = data;
190511
+ this.nodeValue = data;
189831
190512
  }
189832
- }
190513
+ },
189833
190514
  });
189834
190515
 
189835
- function getTextContent(node){
189836
- switch(node.nodeType){
189837
- case ELEMENT_NODE:
189838
- case DOCUMENT_FRAGMENT_NODE:
189839
- var buf = [];
189840
- node = node.firstChild;
189841
- while(node){
189842
- if(node.nodeType!==7 && node.nodeType !==8){
189843
- buf.push(getTextContent(node));
189844
- }
189845
- node = node.nextSibling;
189846
- }
189847
- return buf.join('');
189848
- default:
189849
- return node.nodeValue;
189850
- }
189851
- }
189852
-
189853
190516
  __set__ = function(object,key,value){
189854
190517
  //console.log(value)
189855
190518
  object['$$'+key] = value;
@@ -189865,6 +190528,7 @@ function requireDom () {
189865
190528
  dom.Element = Element;
189866
190529
  dom.Node = Node;
189867
190530
  dom.NodeList = NodeList;
190531
+ dom.walkDOM = walkDOM;
189868
190532
  dom.XMLSerializer = XMLSerializer;
189869
190533
  //}
189870
190534
  return dom;
@@ -189879,7 +190543,7 @@ var hasRequiredEntities;
189879
190543
  function requireEntities () {
189880
190544
  if (hasRequiredEntities) return entities;
189881
190545
  hasRequiredEntities = 1;
189882
- (function (exports$1) {
190546
+ (function (exports) {
189883
190547
 
189884
190548
  var freeze = requireConventions().freeze;
189885
190549
 
@@ -189890,7 +190554,7 @@ function requireEntities () {
189890
190554
  * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-predefined-ent W3C XML 1.0
189891
190555
  * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML Wikipedia
189892
190556
  */
189893
- exports$1.XML_ENTITIES = freeze({
190557
+ exports.XML_ENTITIES = freeze({
189894
190558
  amp: '&',
189895
190559
  apos: "'",
189896
190560
  gt: '>',
@@ -189912,7 +190576,7 @@ function requireEntities () {
189912
190576
  * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML Wikipedia (HTML)
189913
190577
  * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML Wikpedia (XHTML)
189914
190578
  */
189915
- exports$1.HTML_ENTITIES = freeze({
190579
+ exports.HTML_ENTITIES = freeze({
189916
190580
  Aacute: '\u00C1',
189917
190581
  aacute: '\u00E1',
189918
190582
  Abreve: '\u0102',
@@ -192044,7 +192708,7 @@ function requireEntities () {
192044
192708
  * @deprecated use `HTML_ENTITIES` instead
192045
192709
  * @see HTML_ENTITIES
192046
192710
  */
192047
- exports$1.entityMap = exports$1.HTML_ENTITIES;
192711
+ exports.entityMap = exports.HTML_ENTITIES;
192048
192712
  } (entities));
192049
192713
  return entities;
192050
192714
  }
@@ -192057,14 +192721,8 @@ function requireSax () {
192057
192721
  if (hasRequiredSax) return sax;
192058
192722
  hasRequiredSax = 1;
192059
192723
  var NAMESPACE = requireConventions().NAMESPACE;
192724
+ var tagNamePattern = requireConventions().tagNamePattern;
192060
192725
 
192061
- //[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
192062
- //[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
192063
- //[5] Name ::= NameStartChar (NameChar)*
192064
- var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;//\u10000-\uEFFFF
192065
- var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
192066
- var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');
192067
- //var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/
192068
192726
  //var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')
192069
192727
 
192070
192728
  //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
@@ -192175,7 +192833,13 @@ function requireSax () {
192175
192833
  switch(source.charAt(tagStart+1)){
192176
192834
  case '/':
192177
192835
  var end = source.indexOf('>',tagStart+3);
192178
- var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, '');
192836
+ // Anchored trailing-whitespace trim. The former `/[ \t\n\r]+$/g` backtracked
192837
+ // quadratically on a name shaped `whitespace-run + non-whitespace char`
192838
+ // (an end tag `</ … x>`): from every start position it extended `[ws]+`
192839
+ // to the end and then failed the `$` anchor. This anchored form matches the
192840
+ // whole string once and captures everything up to the last non-whitespace
192841
+ // character, so it trims in linear time with byte-identical output.
192842
+ var tagName = source.substring(tagStart + 2, end).replace(/^([\s\S]*?[^ \t\n\r])?[ \t\n\r]*$/, '$1');
192179
192843
  var config = parseStack.pop();
192180
192844
  if(end<0){
192181
192845
 
@@ -192186,6 +192850,14 @@ function requireSax () {
192186
192850
  tagName = tagName.replace(/[\s<].*/,'');
192187
192851
  errorHandler.error("end tag name: "+tagName+' maybe not complete');
192188
192852
  end = tagStart+1+tagName.length;
192853
+ }else if(/[ \t\n\r]/.test(tagName) && tagNamePattern.test(tagName.split(/[ \t\n\r]/)[0])){
192854
+ // The XML `ETag` production is `'</' Name S? '>'`: only optional whitespace may follow
192855
+ // the `Name`. A valid `Name` followed by whitespace and non-whitespace residue (e.g.
192856
+ // `</a\nbogus>` or `</a bogus>`) is not well-formed, but historically it was silently
192857
+ // accepted (the malformed end tag ignored, the residue dropped, the element left on the
192858
+ // stack). Report it as a recoverable `error` (which a custom errorHandler may escalate to
192859
+ // fatal) while keeping the existing recovery so the parsed DOM stays byte-identical.
192860
+ errorHandler.error('end tag name is followed by whitespace and trailing content: "'+tagName+'"');
192189
192861
  }
192190
192862
  var localNSMap = config.localNSMap;
192191
192863
  var endMatch = config.tagName == tagName;
@@ -192309,6 +192981,15 @@ function requireSax () {
192309
192981
  var s = S_TAG;//status
192310
192982
  while(true){
192311
192983
  var c = source.charAt(p);
192984
+ if (s === S_TAG && c === '<') {
192985
+ // A `<` can never occur inside a tag name. Without this guard the scan runs
192986
+ // on to the next `>` (or EOF) before the tag name is rejected, so a document
192987
+ // with many `<` inside a malformed tag makes each one-character recovery step
192988
+ // re-scan to the distant `>` — O(n^2). Stopping at the `<` keeps each recovery
192989
+ // step bounded. The candidate scanned so far is reported raw, consistent with
192990
+ // the sibling invalid-tag-name throw below.
192991
+ throw new Error('unexpected < in tag name: ' + source.slice(start, p));
192992
+ }
192312
192993
  switch(c){
192313
192994
  case '=':
192314
192995
  if(s === S_ATTR){//attrName
@@ -192501,9 +193182,13 @@ function requireSax () {
192501
193182
  if(nsPrefix !== false){//hack!!
192502
193183
  if(localNSMap == null){
192503
193184
  localNSMap = {};
192504
- //console.log(currentNSMap,0)
192505
- _copy(currentNSMap,currentNSMap={});
192506
- //console.log(currentNSMap,1)
193185
+ // Derive the child scope's namespace map by prototype-chain inheritance
193186
+ // instead of a flat copy: lookups inherit ancestor prefixes transparently,
193187
+ // so a document nesting N scopes retains O(N) map entries rather than
193188
+ // sum(1..N) = O(N^2). localNSMap stays a flat own-only record of the
193189
+ // prefixes declared at THIS element, so own-property enumeration
193190
+ // (endPrefixMapping below) still reports only local declarations.
193191
+ currentNSMap = Object.create(currentNSMap);
192507
193192
  }
192508
193193
  currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
192509
193194
  a.uri = NAMESPACE.XMLNS;
@@ -192655,7 +193340,7 @@ function requireSax () {
192655
193340
  function parseInstruction(source,start,domBuilder){
192656
193341
  var end = source.indexOf('?>',start);
192657
193342
  if(end){
192658
- var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
193343
+ var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)$/);
192659
193344
  if(match){
192660
193345
  match[0].length;
192661
193346
  domBuilder.processingInstruction(match[1], match[2]) ;
@@ -193852,7 +194537,7 @@ var hasRequiredMoment;
193852
194537
  function requireMoment () {
193853
194538
  if (hasRequiredMoment) return moment$1.exports;
193854
194539
  hasRequiredMoment = 1;
193855
- (function (module, exports$1) {
194540
+ (function (module, exports) {
193856
194541
  (function (global, factory) {
193857
194542
  module.exports = factory() ;
193858
194543
  }(this, (function () {
@@ -199542,7 +200227,7 @@ function requireMomentTimezone () {
199542
200227
  hasRequiredMomentTimezone = 1;
199543
200228
  (function (module) {
199544
200229
  //! moment-timezone.js
199545
- //! version : 0.6.0
200230
+ //! version : 0.6.3
199546
200231
  //! Copyright (c) JS Foundation and other contributors
199547
200232
  //! license : MIT
199548
200233
  //! github.com/moment/moment-timezone
@@ -199568,7 +200253,7 @@ function requireMomentTimezone () {
199568
200253
  // return moment;
199569
200254
  // }
199570
200255
 
199571
- var VERSION = "0.6.0",
200256
+ var VERSION = "0.6.3",
199572
200257
  zones = {},
199573
200258
  links = {},
199574
200259
  countries = {},
@@ -203064,11 +203749,11 @@ var DEFAULT_FORMATS;
203064
203749
  DEFAULT_FORMATS["DATE_TIME"] = "yyyy-MM-dd HH:mm:ss";
203065
203750
  })(DEFAULT_FORMATS || (DEFAULT_FORMATS = {}));
203066
203751
 
203067
- const $RAF = window.requestAnimationFrame;
203752
+ const $RAF$1 = window.requestAnimationFrame;
203068
203753
  const $RAFQueue = [];
203069
203754
  const invokeLater = fn => {
203070
203755
  if (!$RAFQueue.length) {
203071
- $RAF(() => {
203756
+ $RAF$1(() => {
203072
203757
  $RAFQueue.forEach(f => f());
203073
203758
  $RAFQueue.length = 0;
203074
203759
  });
@@ -203610,220 +204295,70 @@ const getFnForEventExpr = (expr) => {
203610
204295
  return fnExecutor(expr, ExpressionType.Action);
203611
204296
  };
203612
204297
 
203613
- // Constants
203614
- const WIDGET_ID_REGEX = /^(widget-[^_]+)/;
203615
- const WIDGET_PROPERTY_REGEX = /^widget-[^_]+_(.+)$/;
203616
- const ARRAY_INDEX_PLACEHOLDER = '[$i]';
203617
- const ARRAY_INDEX_ZERO = '[0]';
203618
204298
  const registry = new Map();
203619
204299
  const watchIdGenerator = new IDGenerator('watch-id-');
203620
- const FIRST_TIME_WATCH = Object.freeze({});
203621
- /**
203622
- * Extracts widget ID from identifier (e.g., "widget-id23_eventsource" -> "widget-id23")
203623
- */
203624
- const getWidgetId = (identifier) => {
203625
- if (!identifier || typeof identifier !== 'string') {
203626
- return null;
203627
- }
203628
- const match = identifier.match(WIDGET_ID_REGEX);
203629
- return match ? match[1] : null;
203630
- };
203631
- /**
203632
- * Extracts property name from identifier (e.g., "widget-id23_eventsource" -> "eventsource")
203633
- */
203634
- const getPropertyName = (identifier) => {
203635
- if (!identifier || typeof identifier !== 'string') {
203636
- return identifier;
203637
- }
203638
- const match = identifier.match(WIDGET_PROPERTY_REGEX);
203639
- return match ? match[1] : identifier;
203640
- };
203641
- /**
203642
- * Array consumer wrapper for array-based expressions
203643
- */
204300
+ const FIRST_TIME_WATCH = {};
204301
+ Object.freeze(FIRST_TIME_WATCH);
203644
204302
  const arrayConsumer = (listenerFn, restExpr, newVal, oldVal) => {
203645
- if (!isArray(newVal)) {
203646
- return;
203647
- }
203648
- let formattedData = newVal.map(datum => findValueOf(datum, restExpr));
203649
- // Flatten if result is array of arrays
203650
- if (isArray(formattedData[0])) {
203651
- formattedData = flatten(formattedData);
204303
+ let data = newVal, formattedData;
204304
+ if (isArray(data)) {
204305
+ formattedData = data.map(function (datum) {
204306
+ return findValueOf(datum, restExpr);
204307
+ });
204308
+ // If resulting structure is an array of array, flatten it
204309
+ if (isArray(formattedData[0])) {
204310
+ formattedData = flatten(formattedData);
204311
+ }
204312
+ listenerFn(formattedData, oldVal);
203652
204313
  }
203653
- listenerFn(formattedData, oldVal);
203654
204314
  };
203655
- /**
203656
- * Updates watch info for array expressions
203657
- */
203658
- const getUpdatedWatchInfo = (expr, acceptsArray, listener) => {
203659
- const regex = /\[\$i\]/g;
204315
+ const getUpdatedWatcInfo = (expr, acceptsArray, listener) => {
204316
+ // listener doesn't accept array
204317
+ // replace all `[$i]` with `[0]` and return the expression
204318
+ let regex = /\[\$i\]/g, $I = '[$i]', $0 = '[0]';
203660
204319
  if (!acceptsArray) {
203661
204320
  return {
203662
- expr: expr.replace(regex, ARRAY_INDEX_ZERO),
203663
- listener
204321
+ 'expr': expr.replace(regex, $0),
204322
+ 'listener': listener
203664
204323
  };
203665
204324
  }
203666
- const lastIndex = expr.lastIndexOf(ARRAY_INDEX_PLACEHOLDER);
203667
- const baseExpr = expr.substring(0, lastIndex).replace(ARRAY_INDEX_PLACEHOLDER, ARRAY_INDEX_ZERO);
203668
- const restExpr = expr.substring(lastIndex + ARRAY_INDEX_PLACEHOLDER.length);
203669
- const arrayConsumerFn = restExpr
203670
- ? arrayConsumer.bind(undefined, listener, restExpr)
203671
- : listener;
204325
+ // listener accepts array
204326
+ // replace all except the last `[$i]` with `[0]` and return the expression.
204327
+ var index = expr.lastIndexOf($I), _expr = expr.substr(0, index).replace($I, $0), restExpr = expr.substr(index + 5), arrayConsumerFn = listener;
204328
+ if (restExpr) {
204329
+ arrayConsumerFn = arrayConsumer.bind(undefined, listener, restExpr);
204330
+ }
203672
204331
  return {
203673
- expr: baseExpr,
203674
- listener: arrayConsumerFn
204332
+ 'expr': _expr,
204333
+ 'listener': arrayConsumerFn
203675
204334
  };
203676
204335
  };
203677
- /**
203678
- * Determines if an expression is static (doesn't need to be watched)
203679
- */
203680
- const STATIC_EXPRESSION_NAMES = [
203681
- "row.getProperty('investment')",
203682
- "row.getProperty('factsheetLink')",
203683
- "row.getProperty('isRebalanceEligible')"
203684
- ];
203685
- const isStaticExpression = (expr) => {
203686
- if (typeof expr !== 'string') {
203687
- return false;
203688
- }
203689
- const trimmedExpr = expr.trim();
203690
- // Expressions that always evaluate to localization strings
203691
- if (trimmedExpr.includes('appLocale')) {
203692
- return true;
203693
- }
203694
- // Hard-coded static expression names
203695
- if (STATIC_EXPRESSION_NAMES.includes(trimmedExpr)) {
203696
- return true;
203697
- }
203698
- return false;
203699
- };
203700
- /**
203701
- * Gets the scope type from the scope object
203702
- */
203703
- const getScopeType = ($scope) => {
203704
- if (!$scope) {
203705
- return null;
203706
- }
203707
- if ($scope.pageName)
203708
- return 'Page';
203709
- if ($scope.prefabName)
203710
- return 'Prefab';
203711
- if ($scope.partialName)
203712
- return 'Partial';
203713
- // Check for App scope
203714
- if ($scope.Variables !== undefined &&
203715
- $scope.Actions !== undefined &&
203716
- !$scope.pageName &&
203717
- !$scope.prefabName &&
203718
- !$scope.partialName) {
203719
- return 'App';
203720
- }
203721
- if ($scope.constructor?.name === 'AppRef') {
203722
- return 'App';
203723
- }
203724
- return null;
203725
- };
203726
- /**
203727
- * Gets scope name based on scope type
203728
- */
203729
- const getScopeName = ($scope, scopeType) => {
203730
- if (!scopeType || !$scope) {
203731
- return null;
203732
- }
203733
- switch (scopeType) {
203734
- case 'Prefab': return $scope.prefabName || null;
203735
- case 'Partial': return $scope.partialName || null;
203736
- case 'Page': return $scope.pageName || null;
203737
- default: return null;
203738
- }
203739
- };
203740
- /**
203741
- * Main watch function
203742
- */
203743
204336
  const $watch = (expr, $scope, $locals, listener, identifier = watchIdGenerator.nextUid(), doNotClone = false, config = {}, isMuted) => {
203744
- // Handle array expressions
203745
- if (expr.includes(ARRAY_INDEX_PLACEHOLDER)) {
203746
- const watchInfo = getUpdatedWatchInfo(expr, config.arrayType || config.isList || false, listener);
204337
+ if (expr.indexOf('[$i]') !== -1) {
204338
+ let watchInfo = getUpdatedWatcInfo(expr, config && (config.arrayType || config.isList), listener);
203747
204339
  expr = watchInfo.expr;
203748
204340
  listener = watchInfo.listener;
203749
204341
  }
203750
- // Handle static expressions
203751
- if (isStaticExpression(expr)) {
203752
- try {
203753
- const fn = $parseExpr(expr);
203754
- const staticValue = fn($scope, $locals);
203755
- listener(staticValue, FIRST_TIME_WATCH);
203756
- }
203757
- catch (e) {
203758
- console.warn(`Error evaluating static expression '${expr}':`, e);
203759
- listener(undefined, FIRST_TIME_WATCH);
203760
- }
203761
- return () => { }; // No-op unsubscribe
203762
- }
203763
204342
  const fn = $parseExpr();
203764
- const scopeType = getScopeType($scope);
203765
- const scopeName = getScopeName($scope, scopeType);
203766
- const watchInfo = {
203767
- fn: fn.bind(null, $scope, $locals),
204343
+ registry.set(identifier, {
204344
+ fn: fn.bind(expr, $scope, $locals),
203768
204345
  listener,
203769
204346
  expr,
203770
204347
  last: FIRST_TIME_WATCH,
203771
204348
  doNotClone,
203772
- isMuted,
203773
- scopeType,
203774
- scopeName
203775
- };
203776
- // Store in registry
203777
- const widgetId = getWidgetId(identifier);
203778
- if (widgetId) {
203779
- const propertyName = getPropertyName(identifier);
203780
- if (!registry.has(widgetId)) {
203781
- registry.set(widgetId, {});
203782
- }
203783
- const widgetGroup = registry.get(widgetId);
203784
- widgetGroup[propertyName] = watchInfo;
203785
- }
203786
- else {
203787
- registry.set(identifier, watchInfo);
203788
- }
204349
+ isMuted: isMuted
204350
+ });
203789
204351
  return () => $unwatch(identifier);
203790
204352
  };
203791
- /**
203792
- * Unwatches a single identifier
203793
- */
203794
- const $unwatch = (identifier) => {
203795
- const widgetId = getWidgetId(identifier);
203796
- if (widgetId) {
203797
- const propertyName = getPropertyName(identifier);
203798
- const widgetGroup = registry.get(widgetId);
203799
- if (widgetGroup && typeof widgetGroup === 'object' && !widgetGroup.fn) {
203800
- const watchInfo = widgetGroup[propertyName];
203801
- if (watchInfo) {
203802
- delete widgetGroup[propertyName];
203803
- // Clean up empty widget groups
203804
- if (Object.keys(widgetGroup).length === 0) {
203805
- registry.delete(widgetId);
203806
- }
203807
- return true;
203808
- }
203809
- }
203810
- }
203811
- // Fallback to direct lookup
203812
- if (registry.has(identifier)) {
203813
- registry.delete(identifier);
203814
- return true;
203815
- }
203816
- return false;
203817
- };
204353
+ const $unwatch = identifier => registry.delete(identifier);
204354
+ window.watchRegistry = registry;
203818
204355
  const $appDigest = (() => {
203819
- return (force = false) => {
204356
+ return (force) => {
203820
204357
  {
203821
204358
  return;
203822
204359
  }
203823
204360
  };
203824
204361
  })();
203825
- // Export registry for debugging
203826
- // (window as any).watchRegistry = registry;
203827
204362
 
203828
204363
  var ComponentType;
203829
204364
  (function (ComponentType) {
@@ -203879,8 +204414,6 @@ var Operation;
203879
204414
  const DataSource = {
203880
204415
  Operation
203881
204416
  };
203882
- class App {
203883
- }
203884
204417
  class AbstractI18nService {
203885
204418
  }
203886
204419
 
@@ -203898,7 +204431,6 @@ const REGEX = {
203898
204431
  SUPPORTED_AUDIO_FORMAT: /\.(mp3|ogg|webm|wma|3gp|wav|m4a)$/i,
203899
204432
  SUPPORTED_VIDEO_FORMAT: /\.(mp4|ogg|webm|wmv|mpeg|mpg|avi|mov)$/i,
203900
204433
  VALID_WEB_URL: /^(http[s]?:\/\/)(www\.){0,1}[a-zA-Z0-9=:?\/\.\-]+(\.[a-zA-Z]{2,5}[\.]{0,1})?/,
203901
- VALID_IMAGE_URL: /^(https?|blob|data|file|ftp):/i,
203902
204434
  REPLACE_PATTERN: /\$\{([^\}]+)\}/g,
203903
204435
  DATA_URL: /^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*)\s*$/i,
203904
204436
  ISO_DATE_FORMAT: /(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})(\.\d+)?([+-]\d{2}:?\d{2}|Z)$/
@@ -204121,9 +204653,6 @@ const isVideoFile = (fileName) => {
204121
204653
  const isValidWebURL = (url) => {
204122
204654
  return (REGEX.VALID_WEB_URL).test(url);
204123
204655
  };
204124
- const isValidImageUrl = (url) => {
204125
- return (REGEX.VALID_IMAGE_URL).test(url?.trim());
204126
- };
204127
204656
  /*This function returns the url to the resource after checking the validity of url*/
204128
204657
  const getResourceURL = (urlString) => {
204129
204658
  return urlString;
@@ -205377,7 +205906,6 @@ var Utils = /*#__PURE__*/Object.freeze({
205377
205906
  isPageable: isPageable,
205378
205907
  isSafari: isSafari,
205379
205908
  isTablet: isTablet,
205380
- isValidImageUrl: isValidImageUrl,
205381
205909
  isValidWebURL: isValidWebURL,
205382
205910
  isVideoFile: isVideoFile,
205383
205911
  loadScript: loadScript,
@@ -208217,7 +208745,7 @@ class PipeProvider {
208217
208745
  this.preparePipeMeta(CurrencyPipe$1, 'currency', true, [this._locale]),
208218
208746
  this.preparePipeMeta(DatePipe$1, 'date', true, [this._locale]),
208219
208747
  this.preparePipeMeta(ToDatePipe, 'toDate', true, [
208220
- new DatePipe$1(this._locale), undefined, this.injector.get(App), this.injector.get(CustomPipeManager)
208748
+ new DatePipe$1(this._locale), undefined, this.injector.get(CustomPipeManager)
208221
208749
  ]),
208222
208750
  this.preparePipeMeta(ToNumberPipe, 'toNumber', true, [
208223
208751
  new DecimalPipe$1(this._locale),
@@ -208234,7 +208762,7 @@ class PipeProvider {
208234
208762
  new DecimalPipe$1(this._locale)
208235
208763
  ]),
208236
208764
  this.preparePipeMeta(StringToNumberPipe, 'stringToNumber', true),
208237
- this.preparePipeMeta(CustomPipe, 'custom', true, [this.injector.get(App), this.injector.get(CustomPipeManager)]),
208765
+ this.preparePipeMeta(CustomPipe, 'custom', true, [this.injector.get(CustomPipeManager)]),
208238
208766
  this.preparePipeMeta(TrustAsPipe, 'trustAs', true, [this.domSanitizer]),
208239
208767
  this.preparePipeMeta(SanitizePipe, 'sanitize', true, [this.domSanitizer]),
208240
208768
  this.preparePipeMeta(TemplateReplacePipe, 'templateReplace', true),