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

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.4
142716
143136
  //! Copyright (c) JS Foundation and other contributors
142717
143137
  //! license : MIT
142718
143138
  //! github.com/moment/moment-timezone
@@ -142738,12 +143158,18 @@ function requireMomentTimezone$1 () {
142738
143158
  // return moment;
142739
143159
  // }
142740
143160
 
142741
- var VERSION = "0.6.0",
143161
+ var VERSION = "0.6.4",
142742
143162
  zones = {},
142743
143163
  links = {},
142744
143164
  countries = {},
142745
143165
  names = {},
142746
143166
  guesses = {},
143167
+ parsingInZone = false,
143168
+ parsingNow,
143169
+ parsingNowFunction,
143170
+ hasParsingNow = false,
143171
+ ignoreDefaultZoneForInput,
143172
+ hasIgnoredDefaultZoneInput = false,
142747
143173
  cachedGuess;
142748
143174
 
142749
143175
  if (!moment || typeof moment.version !== 'string') {
@@ -142915,17 +143341,16 @@ function requireMomentTimezone$1 () {
142915
143341
  offsets = this.offsets,
142916
143342
  untils = this.untils,
142917
143343
  max = untils.length - 1,
142918
- offset, offsetNext, offsetPrev, i;
143344
+ offset, offsetNext, i;
142919
143345
 
142920
143346
  for (i = 0; i < max; i++) {
142921
143347
  offset = offsets[i];
142922
143348
  offsetNext = offsets[i + 1];
142923
- offsetPrev = offsets[i ? i - 1 : i];
142924
143349
 
142925
143350
  if (offset < offsetNext && tz.moveAmbiguousForward) {
142926
143351
  offset = offsetNext;
142927
- } else if (offset > offsetPrev && tz.moveInvalidForward) {
142928
- offset = offsetPrev;
143352
+ } else if (offset > offsetNext && tz.moveInvalidForward) {
143353
+ offset = offsetNext;
142929
143354
  }
142930
143355
 
142931
143356
  if (target < untils[i] - (offset * 60000)) {
@@ -142950,6 +143375,15 @@ function requireMomentTimezone$1 () {
142950
143375
  }
142951
143376
  };
142952
143377
 
143378
+ var utcDefaultZone = new Zone();
143379
+ utcDefaultZone._set({
143380
+ name : 'UTC',
143381
+ abbrs : ['UTC'],
143382
+ untils : [Infinity],
143383
+ offsets : [0],
143384
+ population : 0
143385
+ });
143386
+
142953
143387
  /************************************
142954
143388
  Country object
142955
143389
  ************************************/
@@ -143287,6 +143721,85 @@ function requireMomentTimezone$1 () {
143287
143721
  return !!(m._a && (m._tzm === undefined) && !isUnixTimestamp);
143288
143722
  }
143289
143723
 
143724
+ function isObjectInput (input) {
143725
+ var prop;
143726
+
143727
+ if (moment.isMoment(input) || input === null || Object.prototype.toString.call(input) !== '[object Object]') {
143728
+ return false;
143729
+ }
143730
+ if (Object.getOwnPropertyNames) {
143731
+ return Object.getOwnPropertyNames(input).length > 0;
143732
+ }
143733
+ for (prop in input) {
143734
+ if (Object.prototype.hasOwnProperty.call(input, prop)) {
143735
+ return true;
143736
+ }
143737
+ }
143738
+ return false;
143739
+ }
143740
+
143741
+ function parseWithZoneNow (args, name, stringInput) {
143742
+ var savedNow = moment.now,
143743
+ savedDefaultZone = moment.defaultZone,
143744
+ savedParsingInZone = parsingInZone,
143745
+ savedParsingNow = parsingNow,
143746
+ savedParsingNowFunction = parsingNowFunction,
143747
+ savedHasParsingNow = hasParsingNow,
143748
+ now,
143749
+ hasNow = false,
143750
+ zonedNow,
143751
+ wallNow,
143752
+ parsedDateParts,
143753
+ out;
143754
+
143755
+ if (!parsingInZone) {
143756
+ parsingNow = undefined;
143757
+ parsingNowFunction = savedNow;
143758
+ hasParsingNow = false;
143759
+ }
143760
+ parsingInZone = true;
143761
+ moment.now = function () {
143762
+ if (!hasNow) {
143763
+ if (!hasParsingNow) {
143764
+ parsingNow = parsingNowFunction.call(moment);
143765
+ hasParsingNow = true;
143766
+ }
143767
+ now = parsingNow;
143768
+ hasNow = true;
143769
+ zonedNow = moment.tz(now, name);
143770
+ wallNow = zonedNow.valueOf() + zonedNow.utcOffset() * 60000;
143771
+ }
143772
+ return wallNow;
143773
+ };
143774
+ if (stringInput) {
143775
+ moment.defaultZone = utcDefaultZone;
143776
+ }
143777
+ try {
143778
+ out = moment.utc.apply(null, args);
143779
+ if (stringInput && hasNow && out._a && out._tzm !== undefined) {
143780
+ parsedDateParts = out.parsingFlags().parsedDateParts;
143781
+ if (!parsedDateParts || parsedDateParts[0] == null || parsedDateParts[1] == null || parsedDateParts[2] == null) {
143782
+ moment.now = function () {
143783
+ return now;
143784
+ };
143785
+ moment.defaultZone = savedDefaultZone;
143786
+ out = moment.utc.apply(null, args);
143787
+ }
143788
+ }
143789
+ } finally {
143790
+ moment.now = savedNow;
143791
+ moment.defaultZone = savedDefaultZone;
143792
+ parsingInZone = savedParsingInZone;
143793
+ if (!savedParsingInZone) {
143794
+ parsingNow = savedParsingNow;
143795
+ parsingNowFunction = savedParsingNowFunction;
143796
+ hasParsingNow = savedHasParsingNow;
143797
+ }
143798
+ }
143799
+
143800
+ return out;
143801
+ }
143802
+
143290
143803
  function logError (message) {
143291
143804
  if (typeof console !== 'undefined' && typeof console.error === 'function') {
143292
143805
  console.error(message);
@@ -143300,10 +143813,13 @@ function requireMomentTimezone$1 () {
143300
143813
  function tz (input) {
143301
143814
  var args = Array.prototype.slice.call(arguments, 0, -1),
143302
143815
  name = arguments[arguments.length - 1],
143303
- out = moment.utc.apply(null, args),
143304
- zone;
143816
+ objectInput = isObjectInput(input),
143817
+ stringInput = args.length > 0 && typeof input === 'string',
143818
+ zone = objectInput || stringInput ? getZone(name) : null,
143819
+ out = objectInput && zone ? parseWithZoneNow(args, name) :
143820
+ stringInput && zone ? parseWithZoneNow(args, name, true) : moment.utc.apply(null, args);
143305
143821
 
143306
- if (!moment.isMoment(input) && needsOffset(out) && (zone = getZone(name))) {
143822
+ if (!moment.isMoment(input) && needsOffset(out) && (zone || (!objectInput && (zone = getZone(name))))) {
143307
143823
  out.add(zone.parse(out), 'minutes');
143308
143824
  }
143309
143825
 
@@ -143343,10 +143859,49 @@ function requireMomentTimezone$1 () {
143343
143859
  moment.tz = tz;
143344
143860
 
143345
143861
  moment.defaultZone = null;
143862
+ var momentGetDefaultDateParts = moment._getDefaultDateParts;
143863
+ if (momentGetDefaultDateParts) {
143864
+ moment._getDefaultDateParts = function (config, now, forWeek) {
143865
+ var zone = moment.defaultZone,
143866
+ zonedNow,
143867
+ dateParts,
143868
+ savedIgnoredInput,
143869
+ savedHasIgnoredInput;
143870
+ forWeek = forWeek || config._isDefaultDatePartsForWeek;
143871
+
143872
+ if (parsingInZone && config._tzm === undefined) {
143873
+ zonedNow = new Date(now);
143874
+ return [zonedNow.getUTCFullYear(), zonedNow.getUTCMonth(), zonedNow.getUTCDate()];
143875
+ }
143876
+
143877
+ if (zone && !config._useUTC && config._tzm === undefined) {
143878
+ zonedNow = new Date(now - zone.utcOffset(now) * 60000);
143879
+ return [zonedNow.getUTCFullYear(), zonedNow.getUTCMonth(), zonedNow.getUTCDate()];
143880
+ }
143881
+
143882
+ if (forWeek && (config._useUTC || config._tzm !== undefined)) {
143883
+ savedIgnoredInput = ignoreDefaultZoneForInput;
143884
+ savedHasIgnoredInput = hasIgnoredDefaultZoneInput;
143885
+ ignoreDefaultZoneForInput = now;
143886
+ hasIgnoredDefaultZoneInput = true;
143887
+ try {
143888
+ dateParts = momentGetDefaultDateParts.call(this, config, now, forWeek);
143889
+ } finally {
143890
+ ignoreDefaultZoneForInput = savedIgnoredInput;
143891
+ hasIgnoredDefaultZoneInput = savedHasIgnoredInput;
143892
+ }
143893
+ return dateParts;
143894
+ }
143895
+
143896
+ return momentGetDefaultDateParts.call(this, config, now, forWeek);
143897
+ };
143898
+ }
143346
143899
 
143347
143900
  moment.updateOffset = function (mom, keepTime) {
143348
- var zone = moment.defaultZone,
143349
- offset;
143901
+ var zone = hasIgnoredDefaultZoneInput && ignoreDefaultZoneForInput === mom._i ? null : moment.defaultZone,
143902
+ offset,
143903
+ localTimestamp,
143904
+ normalizedTimestamp;
143350
143905
 
143351
143906
  if (mom._z === undefined) {
143352
143907
  if (zone && needsOffset(mom) && !mom._isUTC && mom.isValid()) {
@@ -143357,6 +143912,20 @@ function requireMomentTimezone$1 () {
143357
143912
  }
143358
143913
  if (mom._z) {
143359
143914
  offset = mom._z.utcOffset(mom);
143915
+ if (keepTime) {
143916
+ // Resolve local times inside a forward gap using the configured
143917
+ // invalid-input policy before applying the new offset.
143918
+ localTimestamp = mom._d.valueOf();
143919
+ if (!mom._isUTC) {
143920
+ localTimestamp -= mom._d.getTimezoneOffset() * 60000;
143921
+ }
143922
+ if (mom._z.utcOffset(localTimestamp + offset * 60000) !== offset) {
143923
+ offset = mom._z.parse(localTimestamp);
143924
+ localTimestamp += offset * 60000;
143925
+ offset = mom._z.utcOffset(localTimestamp);
143926
+ normalizedTimestamp = localTimestamp - offset * 60000;
143927
+ }
143928
+ }
143360
143929
  if (Math.abs(offset) < 16) {
143361
143930
  offset = offset / 60;
143362
143931
  }
@@ -143367,6 +143936,9 @@ function requireMomentTimezone$1 () {
143367
143936
  } else {
143368
143937
  mom.zone(offset, keepTime);
143369
143938
  }
143939
+ if (normalizedTimestamp != null) {
143940
+ mom._d.setTime(normalizedTimestamp);
143941
+ }
143370
143942
  }
143371
143943
  };
143372
143944
 
@@ -147299,11 +147871,11 @@ const CURRENCY_INFO = {
147299
147871
  }
147300
147872
  };
147301
147873
 
147302
- const $RAF$1 = window.requestAnimationFrame;
147874
+ const $RAF$1$1 = window.requestAnimationFrame;
147303
147875
  const $RAFQueue$1 = [];
147304
147876
  const invokeLater$1 = fn => {
147305
147877
  if (!$RAFQueue$1.length) {
147306
- $RAF$1(() => {
147878
+ $RAF$1$1(() => {
147307
147879
  $RAFQueue$1.forEach(f => f());
147308
147880
  $RAFQueue$1.length = 0;
147309
147881
  });
@@ -147845,220 +148417,70 @@ const getFnForEventExpr$1 = (expr) => {
147845
148417
  return fnExecutor$1(expr, ExpressionType$2.Action);
147846
148418
  };
147847
148419
 
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
148420
  const registry$1 = new Map();
147854
148421
  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
- */
148422
+ const FIRST_TIME_WATCH$1 = {};
148423
+ Object.freeze(FIRST_TIME_WATCH$1);
147879
148424
  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);
148425
+ let data = newVal, formattedData;
148426
+ if (isArray$1(data)) {
148427
+ formattedData = data.map(function (datum) {
148428
+ return findValueOf$1(datum, restExpr);
148429
+ });
148430
+ // If resulting structure is an array of array, flatten it
148431
+ if (isArray$1(formattedData[0])) {
148432
+ formattedData = flatten$2(formattedData);
148433
+ }
148434
+ listenerFn(formattedData, oldVal);
147887
148435
  }
147888
- listenerFn(formattedData, oldVal);
147889
148436
  };
147890
- /**
147891
- * Updates watch info for array expressions
147892
- */
147893
- const getUpdatedWatchInfo$1 = (expr, acceptsArray, listener) => {
147894
- const regex = /\[\$i\]/g;
148437
+ const getUpdatedWatcInfo$1 = (expr, acceptsArray, listener) => {
148438
+ // listener doesn't accept array
148439
+ // replace all `[$i]` with `[0]` and return the expression
148440
+ let regex = /\[\$i\]/g, $I = '[$i]', $0 = '[0]';
147895
148441
  if (!acceptsArray) {
147896
148442
  return {
147897
- expr: expr.replace(regex, ARRAY_INDEX_ZERO$1),
147898
- listener
148443
+ 'expr': expr.replace(regex, $0),
148444
+ 'listener': listener
147899
148445
  };
147900
148446
  }
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;
148447
+ // listener accepts array
148448
+ // replace all except the last `[$i]` with `[0]` and return the expression.
148449
+ var index = expr.lastIndexOf($I), _expr = expr.substr(0, index).replace($I, $0), restExpr = expr.substr(index + 5), arrayConsumerFn = listener;
148450
+ if (restExpr) {
148451
+ arrayConsumerFn = arrayConsumer$1.bind(undefined, listener, restExpr);
148452
+ }
147907
148453
  return {
147908
- expr: baseExpr,
147909
- listener: arrayConsumerFn
148454
+ 'expr': _expr,
148455
+ 'listener': arrayConsumerFn
147910
148456
  };
147911
148457
  };
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
148458
  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);
148459
+ if (expr.indexOf('[$i]') !== -1) {
148460
+ let watchInfo = getUpdatedWatcInfo$1(expr, config && (config.arrayType || config.isList), listener);
147982
148461
  expr = watchInfo.expr;
147983
148462
  listener = watchInfo.listener;
147984
148463
  }
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
148464
  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),
148465
+ registry$1.set(identifier, {
148466
+ fn: fn.bind(expr, $scope, $locals),
148003
148467
  listener,
148004
148468
  expr,
148005
148469
  last: FIRST_TIME_WATCH$1,
148006
148470
  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
- }
148471
+ isMuted: isMuted
148472
+ });
148024
148473
  return () => $unwatch$1(identifier);
148025
148474
  };
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
- };
148475
+ const $unwatch$1 = identifier => registry$1.delete(identifier);
148476
+ window.watchRegistry = registry$1;
148053
148477
  const $appDigest$1 = (() => {
148054
- return (force = false) => {
148478
+ return (force) => {
148055
148479
  {
148056
148480
  return;
148057
148481
  }
148058
148482
  };
148059
148483
  })();
148060
- // Export registry for debugging
148061
- // (window as any).watchRegistry = registry;
148062
148484
 
148063
148485
  var ComponentType$1;
148064
148486
  (function (ComponentType) {
@@ -148114,8 +148536,8 @@ var Operation$1;
148114
148536
  const DataSource$1 = {
148115
148537
  Operation: Operation$1
148116
148538
  };
148117
- let App$1 = class App {
148118
- };
148539
+ class App {
148540
+ }
148119
148541
  let AbstractI18nService$1 = class AbstractI18nService {
148120
148542
  };
148121
148543
 
@@ -148133,7 +148555,6 @@ const REGEX$1 = {
148133
148555
  SUPPORTED_AUDIO_FORMAT: /\.(mp3|ogg|webm|wma|3gp|wav|m4a)$/i,
148134
148556
  SUPPORTED_VIDEO_FORMAT: /\.(mp4|ogg|webm|wmv|mpeg|mpg|avi|mov)$/i,
148135
148557
  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
148558
  REPLACE_PATTERN: /\$\{([^\}]+)\}/g,
148138
148559
  DATA_URL: /^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*)\s*$/i,
148139
148560
  ISO_DATE_FORMAT: /(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})(\.\d+)?([+-]\d{2}:?\d{2}|Z)$/
@@ -148356,9 +148777,6 @@ const isVideoFile$1 = (fileName) => {
148356
148777
  const isValidWebURL$1 = (url) => {
148357
148778
  return (REGEX$1.VALID_WEB_URL).test(url);
148358
148779
  };
148359
- const isValidImageUrl$1 = (url) => {
148360
- return (REGEX$1.VALID_IMAGE_URL).test(url?.trim());
148361
- };
148362
148780
  /*This function returns the url to the resource after checking the validity of url*/
148363
148781
  const getResourceURL$1 = (urlString) => {
148364
148782
  return urlString;
@@ -149612,7 +150030,6 @@ var Utils$1 = /*#__PURE__*/Object.freeze({
149612
150030
  isPageable: isPageable$1,
149613
150031
  isSafari: isSafari$1,
149614
150032
  isTablet: isTablet$1,
149615
- isValidImageUrl: isValidImageUrl$1,
149616
150033
  isValidWebURL: isValidWebURL$1,
149617
150034
  isVideoFile: isVideoFile$1,
149618
150035
  loadScript: loadScript$1,
@@ -150847,14 +151264,14 @@ class ToDatePipe extends WmPipe {
150847
151264
  }
150848
151265
  return this.returnFn('', arguments, this.app.Variables);
150849
151266
  }
150850
- constructor(datePipe, i18nService, app, customPipeManager) {
151267
+ constructor(datePipe, i18nService, customPipeManager) {
150851
151268
  super('toDate', customPipeManager);
150852
151269
  this.datePipe = datePipe;
150853
151270
  this.i18nService = i18nService;
150854
- this.app = app;
150855
151271
  this.customPipeManager = customPipeManager;
151272
+ this.app = inject(App);
150856
151273
  }
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)); }; }
151274
+ static { this.ɵfac = function ToDatePipe_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ToDatePipe)(ɵɵdirectiveInject(DatePipe, 16), ɵɵdirectiveInject(AbstractI18nService$1, 16), ɵɵdirectiveInject(CustomPipeManager$1, 16)); }; }
150858
151275
  static { this.ɵpipe = /*@__PURE__*/ ɵɵdefinePipe({ name: "toDate", type: ToDatePipe, pure: true, standalone: true }); }
150859
151276
  }
150860
151277
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(ToDatePipe, [{
@@ -150863,7 +151280,7 @@ class ToDatePipe extends WmPipe {
150863
151280
  standalone: true,
150864
151281
  name: 'toDate'
150865
151282
  }]
150866
- }], () => [{ type: DatePipe }, { type: AbstractI18nService$1 }, { type: App$1 }, { type: CustomPipeManager$1 }], null); })();
151283
+ }], () => [{ type: DatePipe }, { type: AbstractI18nService$1 }, { type: CustomPipeManager$1 }], null); })();
150867
151284
  class ToNumberPipe {
150868
151285
  transform(data, fracSize) {
150869
151286
  if (fracSize && !String(fracSize).match(/^(\d+)?\.((\d+)(-(\d+))?)?$/)) {
@@ -150951,9 +151368,9 @@ class SuffixPipe {
150951
151368
  * Custom pipe: It is work as interceptor between the user custom pipe function and angular pipe
150952
151369
  */
150953
151370
  class CustomPipe {
150954
- constructor(app, custmeUserPipe) {
150955
- this.app = app;
151371
+ constructor(custmeUserPipe) {
150956
151372
  this.custmeUserPipe = custmeUserPipe;
151373
+ this.app = inject(App);
150957
151374
  }
150958
151375
  transform(data, pipename) {
150959
151376
  let argumentArr = [];
@@ -150973,7 +151390,7 @@ class CustomPipe {
150973
151390
  return data;
150974
151391
  }
150975
151392
  }
150976
- static { this.ɵfac = function CustomPipe_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || CustomPipe)(ɵɵdirectiveInject(App$1, 16), ɵɵdirectiveInject(CustomPipeManager$1, 16)); }; }
151393
+ static { this.ɵfac = function CustomPipe_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || CustomPipe)(ɵɵdirectiveInject(CustomPipeManager$1, 16)); }; }
150977
151394
  static { this.ɵpipe = /*@__PURE__*/ ɵɵdefinePipe({ name: "custom", type: CustomPipe, pure: true, standalone: true }); }
150978
151395
  }
150979
151396
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(CustomPipe, [{
@@ -150982,7 +151399,7 @@ class CustomPipe {
150982
151399
  standalone: true,
150983
151400
  name: 'custom'
150984
151401
  }]
150985
- }], () => [{ type: App$1 }, { type: CustomPipeManager$1 }], null); })();
151402
+ }], () => [{ type: CustomPipeManager$1 }], null); })();
150986
151403
  class TimeFromNowPipe {
150987
151404
  transform(data) {
150988
151405
  let timestamp;
@@ -158849,14 +159266,14 @@ function createNgModuleType(meta) {
158849
159266
  if (meta.kind === R3NgModuleMetadataKind.Local) {
158850
159267
  return new ExpressionType$1(meta.type.value);
158851
159268
  }
158852
- const { type: moduleType, declarations, exports: exports$1, imports, includeImportTypes, publicDeclarationTypes, } = meta;
159269
+ const { type: moduleType, declarations, exports, imports, includeImportTypes, publicDeclarationTypes, } = meta;
158853
159270
  return new ExpressionType$1(importExpr(Identifiers.NgModuleDeclaration, [
158854
159271
  new ExpressionType$1(moduleType.type),
158855
159272
  publicDeclarationTypes === null
158856
159273
  ? tupleTypeOf(declarations)
158857
159274
  : tupleOfTypes(publicDeclarationTypes),
158858
159275
  includeImportTypes ? tupleTypeOf(imports) : NONE_TYPE,
158859
- tupleTypeOf(exports$1),
159276
+ tupleTypeOf(exports),
158860
159277
  ]));
158861
159278
  }
158862
159279
  /**
@@ -187992,11 +188409,22 @@ function requireConventions () {
187992
188409
  XMLNS: 'http://www.w3.org/2000/xmlns/',
187993
188410
  });
187994
188411
 
188412
+ //[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]
188413
+ //[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
188414
+ //[5] Name ::= NameStartChar (NameChar)*
188415
+ 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
188416
+ var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
188417
+ var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');
188418
+ //var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/
188419
+
187995
188420
  conventions.assign = assign;
187996
188421
  conventions.find = find;
187997
188422
  conventions.freeze = freeze;
187998
188423
  conventions.MIME_TYPE = MIME_TYPE;
187999
188424
  conventions.NAMESPACE = NAMESPACE;
188425
+ conventions.nameStartChar = nameStartChar;
188426
+ conventions.nameChar = nameChar;
188427
+ conventions.tagNamePattern = tagNamePattern;
188000
188428
  return conventions;
188001
188429
  }
188002
188430
 
@@ -188009,6 +188437,7 @@ function requireDom () {
188009
188437
 
188010
188438
  var find = conventions.find;
188011
188439
  var NAMESPACE = conventions.NAMESPACE;
188440
+ var tagNamePattern = conventions.tagNamePattern;
188012
188441
 
188013
188442
  /**
188014
188443
  * A prerequisite for `[].filter`, to drop elements that are empty
@@ -188118,14 +188547,14 @@ function requireDom () {
188118
188547
  ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2);
188119
188548
  var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3);
188120
188549
  ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4);
188121
- ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
188550
+ var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
188122
188551
  ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6);
188123
188552
  ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7);
188124
188553
  var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8);
188125
188554
  ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9);
188126
188555
  var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10);
188127
188556
  //level2
188128
- ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
188557
+ var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
188129
188558
  ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12);
188130
188559
  ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13);
188131
188560
  ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14);
@@ -188175,9 +188604,10 @@ function requireDom () {
188175
188604
  item: function(index) {
188176
188605
  return index >= 0 && index < this.length ? this[index] : null;
188177
188606
  },
188178
- toString:function(isHTML,nodeFilter){
188607
+ toString:function(isHTML,nodeFilter,options){
188608
+ var requireWellFormed = !!options && !!options.requireWellFormed;
188179
188609
  for(var buf = [], i = 0;i<this.length;i++){
188180
- serializeToString(this[i],buf,isHTML,nodeFilter);
188610
+ serializeToString(this[i],buf,isHTML,nodeFilter,null,requireWellFormed);
188181
188611
  }
188182
188612
  return buf.join('');
188183
188613
  },
@@ -188239,6 +188669,13 @@ function requireDom () {
188239
188669
  * used for attributes or DocumentType entities
188240
188670
  */
188241
188671
  function NamedNodeMap() {
188672
+ // nodeName -> Attr membership index; lets the parse-time de-duplication in
188673
+ // setNamedItem resolve an existing attribute in O(1) instead of scanning the
188674
+ // list, so building an element with M attributes costs O(M) rather than O(M^2).
188675
+ // The numbered entries and length remain the sole authority for attribute order.
188676
+ // Object.create(null) so an attribute named __proto__ or constructor is an
188677
+ // ordinary key.
188678
+ this._nameIndex = Object.create(null);
188242
188679
  }
188243
188680
  function _findNodeIndex(list,node){
188244
188681
  var i = list.length;
@@ -188247,12 +188684,27 @@ function requireDom () {
188247
188684
  }
188248
188685
  }
188249
188686
 
188687
+ function _nnmIndexAdd(list, attr) {
188688
+ list._nameIndex[attr.nodeName] = attr;
188689
+ }
188690
+ function _nnmIndexRemove(list, attr) {
188691
+ // Only drop the entry if it still points at this attribute; a replacement with
188692
+ // a different nodeName may already have re-keyed it.
188693
+ if (list._nameIndex[attr.nodeName] === attr) {
188694
+ delete list._nameIndex[attr.nodeName];
188695
+ }
188696
+ }
188697
+
188250
188698
  function _addNamedNode(el,list,newAttr,oldAttr){
188251
188699
  if(oldAttr){
188252
188700
  list[_findNodeIndex(list,oldAttr)] = newAttr;
188701
+ // oldAttr leaves the list; drop its index entry (its nodeName may differ
188702
+ // from newAttr's when the replacement came via setNamedItemNS).
188703
+ _nnmIndexRemove(list, oldAttr);
188253
188704
  }else {
188254
188705
  list[list.length++] = newAttr;
188255
188706
  }
188707
+ _nnmIndexAdd(list, newAttr);
188256
188708
  if(el){
188257
188709
  newAttr.ownerElement = el;
188258
188710
  var doc = el.ownerDocument;
@@ -188271,6 +188723,7 @@ function requireDom () {
188271
188723
  list[i] = list[++i];
188272
188724
  }
188273
188725
  list.length = lastIndex;
188726
+ _nnmIndexRemove(list, attr);
188274
188727
  if(el){
188275
188728
  var doc = el.ownerDocument;
188276
188729
  if(doc){
@@ -188304,7 +188757,11 @@ function requireDom () {
188304
188757
  if(el && el!=this._ownerElement){
188305
188758
  throw new DOMException(INUSE_ATTRIBUTE_ERR);
188306
188759
  }
188307
- var oldAttr = this.getNamedItem(attr.nodeName);
188760
+ // Resolve any existing attribute with the same nodeName through the O(1)
188761
+ // membership index rather than an O(M) scan — this is the parse-dedup hot
188762
+ // path (setAttributeNode per attribute during parse). Absent -> undefined,
188763
+ // matching getNamedItem's contract.
188764
+ var oldAttr = this._nameIndex[attr.nodeName];
188308
188765
  _addNamedNode(this._ownerElement,this,attr,oldAttr);
188309
188766
  return oldAttr;
188310
188767
  },
@@ -188422,13 +188879,28 @@ function requireDom () {
188422
188879
  /**
188423
188880
  * Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.
188424
188881
  *
188425
- * __This behavior is slightly different from the in the specs__:
188882
+ * __This implementation differs from the specification:__
188426
188883
  * - this implementation is not validating names or qualified names
188427
188884
  * (when parsing XML strings, the SAX parser takes care of that)
188428
188885
  *
188886
+ * Note: `internalSubset` can only be introduced via a direct property write to `node.internalSubset` after creation.
188887
+ * Creation-time validation of `publicId`, `systemId` is not enforced.
188888
+ * The serializer-level check covers all mutation vectors, including direct property writes.
188889
+ * `internalSubset` is only serialized as `[ ... ]` when both `publicId` and `systemId` are
188890
+ * absent (empty or `'.'`) — if either external identifier is present, `internalSubset` is
188891
+ * silently omitted from the serialized output.
188892
+ *
188429
188893
  * @param {string} qualifiedName
188430
188894
  * @param {string} [publicId]
188895
+ * The external subset public identifier. Stored verbatim including surrounding quotes.
188896
+ * When serialized with `requireWellFormed: true` (via the 4th-parameter options object),
188897
+ * throws `DOMException` with code `INVALID_STATE_ERR` if the value is non-empty and does
188898
+ * not match the XML `PubidLiteral` production (W3C DOM Parsing §3.2.1.3; XML 1.0 [12]).
188431
188899
  * @param {string} [systemId]
188900
+ * The external subset system identifier. Stored verbatim including surrounding quotes.
188901
+ * When serialized with `requireWellFormed: true`, throws `DOMException` with code
188902
+ * `INVALID_STATE_ERR` if the value is non-empty and does not match the XML `SystemLiteral`
188903
+ * production (W3C DOM Parsing §3.2.1.3; XML 1.0 [11]).
188432
188904
  * @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation
188433
188905
  * or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`
188434
188906
  *
@@ -188494,18 +188966,73 @@ function requireDom () {
188494
188966
  return cloneNode(this.ownerDocument||this,this,deep);
188495
188967
  },
188496
188968
  // 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
- }
188969
+ /**
188970
+ * Puts the specified node and all of its subtree into a "normalized" form. In a normalized
188971
+ * subtree, no text nodes in the subtree are empty and there are no adjacent text nodes.
188972
+ *
188973
+ * Specifically, this method merges any adjacent text nodes (i.e., nodes for which `nodeType`
188974
+ * is `TEXT_NODE`) into a single node with the combined data. It also removes any empty text
188975
+ * nodes.
188976
+ *
188977
+ * This method iteratively traverses all child nodes to normalize all descendant nodes within
188978
+ * the subtree.
188979
+ *
188980
+ * @throws {DOMException}
188981
+ * May throw a DOMException if operations within removeChild or appendData (which are
188982
+ * potentially invoked in this method) do not meet their specific constraints.
188983
+ * @see {@link Node.removeChild}
188984
+ * @see {@link CharacterData.appendData}
188985
+ * @see ../docs/walk-dom.md.
188986
+ */
188987
+ normalize: function () {
188988
+ walkDOM(this, null, {
188989
+ enter: function (node) {
188990
+ // Merge adjacent text children of node before walkDOM schedules them.
188991
+ // walkDOM reads lastChild/previousSibling after enter returns, so the
188992
+ // surviving post-merge children are what it descends into.
188993
+ var child = node.firstChild;
188994
+ while (child) {
188995
+ var next = child.nextSibling;
188996
+ if (next !== null && next.nodeType === TEXT_NODE && child.nodeType === TEXT_NODE) {
188997
+ // Merge the whole run of adjacent text nodes at once: gather the
188998
+ // following text siblings' data, unlink them in a single pass, and
188999
+ // re-index the child list a single time. Per-sibling `removeChild`
189000
+ // (each an O(K) re-index) plus per-sibling `appendData` (each an O(K)
189001
+ // string rebuild) is O(K^2) over a long run of single-character text
189002
+ // nodes; this keeps it O(K). The first text node of the run survives
189003
+ // and carries the concatenated data, preserving node identity and
189004
+ // locator semantics.
189005
+ var tail = [];
189006
+ var sibling = next;
189007
+ while (sibling !== null && sibling.nodeType === TEXT_NODE) {
189008
+ tail.push(sibling.data);
189009
+ sibling = sibling.nextSibling;
189010
+ }
189011
+ // `sibling` is now the first non-text node after the run, or null.
189012
+ var removed = child.nextSibling;
189013
+ while (removed !== sibling) {
189014
+ var following = removed.nextSibling;
189015
+ removed.parentNode = null;
189016
+ removed.previousSibling = null;
189017
+ removed.nextSibling = null;
189018
+ removed = following;
189019
+ }
189020
+ child.nextSibling = sibling;
189021
+ if (sibling !== null) {
189022
+ sibling.previousSibling = child;
189023
+ } else {
189024
+ node.lastChild = child;
189025
+ }
189026
+ child.appendData(tail.join('')); // single O(K) string rebuild
189027
+ _onUpdateChild(node.ownerDocument, node); // single O(K) re-index
189028
+ child = sibling;
189029
+ } else {
189030
+ child = next;
189031
+ }
189032
+ }
189033
+ return true; // descend into surviving children
189034
+ },
189035
+ });
188509
189036
  },
188510
189037
  // Introduced in DOM Level 2:
188511
189038
  isSupported:function(feature, version){
@@ -188581,21 +189108,103 @@ function requireDom () {
188581
189108
  copy(NodeType,Node.prototype);
188582
189109
 
188583
189110
  /**
188584
- * @param callback return true for continue,false for break
188585
- * @return boolean true: break visit;
189111
+ * @param {Node} node
189112
+ * Root of the subtree to visit.
189113
+ * @param {function(Node): boolean} callback
189114
+ * Called for each node in depth-first pre-order. Return a truthy value to stop traversal early.
189115
+ * @return {boolean} `true` if traversal was aborted by the callback, `false` otherwise.
188586
189116
  */
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
- }
189117
+ function _visitNode(node, callback) {
189118
+ return walkDOM(node, null, { enter: function (n) { return callback(n) ? walkDOM.STOP : true; } }) === walkDOM.STOP;
188596
189119
  }
188597
189120
 
189121
+ /**
189122
+ * Depth-first pre/post-order DOM tree walker.
189123
+ *
189124
+ * Visits every node in the subtree rooted at `node`. For each node:
189125
+ *
189126
+ * 1. Calls `callbacks.enter(node, context)` before descending into the node's children. The
189127
+ * return value becomes the `context` passed to each child's `enter` call and to the matching
189128
+ * `exit` call.
189129
+ * 2. If `enter` returns `null` or `undefined`, the node's children are skipped;
189130
+ * sibling traversal continues normally.
189131
+ * 3. If `enter` returns `walkDOM.STOP`, the entire traversal is aborted immediately — no
189132
+ * further `enter` or `exit` calls are made.
189133
+ * 4. `lastChild` and `previousSibling` are read **after** `enter` returns, so `enter` may
189134
+ * safely modify the node's own child list before the walker descends. Modifying siblings of
189135
+ * the current node or any other part of the tree produces unpredictable results: nodes already
189136
+ * queued on the stack are visited regardless of DOM changes, and newly inserted nodes outside
189137
+ * the current child list are never visited.
189138
+ * 5. Calls `callbacks.exit(node, context)` (if provided) after all of a node's children have
189139
+ * been visited, passing the same `context` that `enter`
189140
+ * returned for that node.
189141
+ *
189142
+ * This implementation uses an explicit stack and does not recurse — it is safe on arbitrarily
189143
+ * deep trees.
189144
+ *
189145
+ * @param {Node} node
189146
+ * Root of the subtree to walk.
189147
+ * @param {*} context
189148
+ * Initial context value passed to the root node's `enter`.
189149
+ * @param {{ enter: function(Node, *): *, exit?: function(Node, *): void }} callbacks
189150
+ * @returns {void | walkDOM.STOP}
189151
+ * @see ../docs/walk-dom.md.
189152
+ */
189153
+ function walkDOM(node, context, callbacks) {
189154
+ // Each stack frame is {node, context, phase}:
189155
+ // walkDOM.ENTER — call enter, then push children
189156
+ // walkDOM.EXIT — call exit
189157
+ var stack = [{ node: node, context: context, phase: walkDOM.ENTER }];
189158
+ while (stack.length > 0) {
189159
+ var frame = stack.pop();
189160
+ if (frame.phase === walkDOM.ENTER) {
189161
+ var childContext = callbacks.enter(frame.node, frame.context);
189162
+ if (childContext === walkDOM.STOP) {
189163
+ return walkDOM.STOP;
189164
+ }
189165
+ // Push exit frame before children so it fires after all children are processed (Last In First Out)
189166
+ stack.push({ node: frame.node, context: childContext, phase: walkDOM.EXIT });
189167
+ if (childContext === null || childContext === undefined) {
189168
+ continue; // skip children
189169
+ }
189170
+ // lastChild is read after enter returns, so enter may modify the child list.
189171
+ var child = frame.node.lastChild;
189172
+ // Traverse from lastChild backwards so that pushing onto the stack
189173
+ // naturally yields firstChild on top (processed first).
189174
+ while (child) {
189175
+ stack.push({ node: child, context: childContext, phase: walkDOM.ENTER });
189176
+ child = child.previousSibling;
189177
+ }
189178
+ } else {
189179
+ // frame.phase === walkDOM.EXIT
189180
+ if (callbacks.exit) {
189181
+ callbacks.exit(frame.node, frame.context);
189182
+ }
189183
+ }
189184
+ }
189185
+ }
188598
189186
 
189187
+ /**
189188
+ * Sentinel value returned from a `walkDOM` `enter` callback to abort the entire traversal
189189
+ * immediately.
189190
+ *
189191
+ * @type {symbol}
189192
+ */
189193
+ walkDOM.STOP = Symbol('walkDOM.STOP');
189194
+ /**
189195
+ * Phase constant for a stack frame that has not yet been visited.
189196
+ * The `enter` callback is called and children are scheduled.
189197
+ *
189198
+ * @type {number}
189199
+ */
189200
+ walkDOM.ENTER = 0;
189201
+ /**
189202
+ * Phase constant for a stack frame whose subtree has been fully visited.
189203
+ * The `exit` callback is called.
189204
+ *
189205
+ * @type {number}
189206
+ */
189207
+ walkDOM.EXIT = 1;
188599
189208
 
188600
189209
  function Document(){
188601
189210
  this.ownerDocument = this;
@@ -189199,12 +189808,46 @@ function requireDom () {
189199
189808
  node.appendData(data);
189200
189809
  return node;
189201
189810
  },
189811
+ /**
189812
+ * Returns a new CDATASection node whose data is `data`.
189813
+ *
189814
+ * __This implementation differs from the specification:__
189815
+ * - calling this method on an HTML document does not throw `NotSupportedError`.
189816
+ *
189817
+ * @param {string} data
189818
+ * @returns {CDATASection}
189819
+ * @throws DOMException with code `INVALID_CHARACTER_ERR` if `data` contains `"]]>"`.
189820
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createCDATASection
189821
+ * @see https://dom.spec.whatwg.org/#dom-document-createcdatasection
189822
+ */
189202
189823
  createCDATASection : function(data){
189824
+ if (data.indexOf(']]>') !== -1) {
189825
+ throw new DOMException(INVALID_CHARACTER_ERR, 'data contains "]]>"');
189826
+ }
189203
189827
  var node = new CDATASection();
189204
189828
  node.ownerDocument = this;
189205
189829
  node.appendData(data);
189206
189830
  return node;
189207
189831
  },
189832
+ /**
189833
+ * Returns a ProcessingInstruction node whose target is target and data is data.
189834
+ *
189835
+ * __This implementation differs from the specification:__
189836
+ * - it does not do any input validation on the arguments and doesn't throw "InvalidCharacterError".
189837
+ *
189838
+ * Note: When the resulting document is serialized with `requireWellFormed: true`, the
189839
+ * serializer throws with code `INVALID_STATE_ERR` if `.target` is not a valid XML `NCName`
189840
+ * (a `Name` with no colon) or is an ASCII case-insensitive match for `"xml"`, or if `.data`
189841
+ * contains `?>` (W3C DOM Parsing §3.2.1.7). Without that option the target and data are
189842
+ * emitted verbatim.
189843
+ *
189844
+ * @param {string} target
189845
+ * @param {string} data
189846
+ * @returns {ProcessingInstruction}
189847
+ * @see https://developer.mozilla.org/docs/Web/API/Document/createProcessingInstruction
189848
+ * @see https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
189849
+ * @see https://www.w3.org/TR/DOM-Parsing/#dfn-concept-serialize-xml §3.2.1.7
189850
+ */
189208
189851
  createProcessingInstruction : function(target,data){
189209
189852
  var node = new ProcessingInstruction();
189210
189853
  node.ownerDocument = this;
@@ -189221,7 +189864,27 @@ function requireDom () {
189221
189864
  node.specified = true;
189222
189865
  return node;
189223
189866
  },
189867
+ /**
189868
+ * Creates an EntityReference object, serialized as `&name;`.
189869
+ *
189870
+ * The `name` is validated against the XML `Name` production at creation time; an invalid name
189871
+ * throws a `DOMException` with code `INVALID_CHARACTER_ERR`. When the resulting node is
189872
+ * serialized with `requireWellFormed: true`, the serializer re-validates `nodeName` and throws
189873
+ * a `DOMException` with code `INVALID_STATE_ERR` if a later `nodeName` mutation made it invalid;
189874
+ * without that option the name is emitted verbatim.
189875
+ *
189876
+ * Note: xmldom does not expand entities — the parser resolves entity references inline and never
189877
+ * constructs `EntityReference` nodes, so this method is the only producer.
189878
+ *
189879
+ * @param {string} name The name of the entity to reference.
189880
+ * @returns {EntityReference}
189881
+ * @throws {DOMException} With code `INVALID_CHARACTER_ERR` when `name` is not a valid XML `Name`.
189882
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-392B75AE
189883
+ */
189224
189884
  createEntityReference : function(name){
189885
+ if (!tagNamePattern.test(name)) {
189886
+ throw new DOMException(INVALID_CHARACTER_ERR, 'not a valid xml name "' + name + '"');
189887
+ }
189225
189888
  var node = new EntityReference();
189226
189889
  node.ownerDocument = this;
189227
189890
  node.nodeName = name;
@@ -189430,6 +190093,20 @@ function requireDom () {
189430
190093
  _extends(CDATASection,CharacterData);
189431
190094
 
189432
190095
 
190096
+ /**
190097
+ * Represents a DocumentType node (the `<!DOCTYPE ...>` declaration).
190098
+ *
190099
+ * `name`, `publicId`, `systemId`, and `internalSubset` are plain own-property assignments.
190100
+ * xmldom does not enforce the `readonly` constraint declared by the WHATWG DOM spec —
190101
+ * direct property writes succeed silently. Values are serialized verbatim when
190102
+ * `requireWellFormed` is false (the default). When the serializer is invoked with
190103
+ * `requireWellFormed: true` (via the 4th-parameter options object), it validates each
190104
+ * field — including `name`, which is checked against the XML `Name` production — and throws
190105
+ * `DOMException` with code `INVALID_STATE_ERR` on invalid values.
190106
+ *
190107
+ * @class
190108
+ * @see https://developer.mozilla.org/docs/Web/API/DocumentType MDN
190109
+ */
189433
190110
  function DocumentType() {
189434
190111
  } DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
189435
190112
  _extends(DocumentType,Node);
@@ -189442,6 +190119,20 @@ function requireDom () {
189442
190119
  } Entity.prototype.nodeType = ENTITY_NODE;
189443
190120
  _extends(Entity,Node);
189444
190121
 
190122
+ /**
190123
+ * Represents an EntityReference node, serialized as `&nodeName;`.
190124
+ *
190125
+ * `nodeName` is the referenced entity's name, stored verbatim. When serialized with
190126
+ * `requireWellFormed: true`, the serializer validates `nodeName` against the XML `Name` production
190127
+ * and throws a `DOMException` with code `INVALID_STATE_ERR` if it does not match; without that
190128
+ * option the name is emitted verbatim between `&` and `;`.
190129
+ *
190130
+ * Note: xmldom does not expand entities — the parser resolves entity references inline and never
190131
+ * constructs `EntityReference` nodes, so the only producer is `Document.createEntityReference`.
190132
+ *
190133
+ * @class
190134
+ * @see https://www.w3.org/TR/xml/#NT-Name
190135
+ */
189445
190136
  function EntityReference() {
189446
190137
  } EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
189447
190138
  _extends(EntityReference,Node);
@@ -189457,11 +190148,54 @@ function requireDom () {
189457
190148
  ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
189458
190149
  _extends(ProcessingInstruction,Node);
189459
190150
  function XMLSerializer(){}
189460
- XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter){
189461
- return nodeSerializeToString.call(node,isHtml,nodeFilter);
190151
+ /**
190152
+ * Returns the result of serializing `node` to XML.
190153
+ *
190154
+ * When `options.requireWellFormed` is `true`, the serializer throws for content that would
190155
+ * produce ill-formed XML.
190156
+ *
190157
+ * __This implementation differs from the specification:__
190158
+ * - CDATASection nodes whose data contains `]]>` are serialized by splitting the section
190159
+ * at each `]]>` occurrence (following W3C DOM Level 3 Core `split-cdata-sections`
190160
+ * default behaviour) unless `requireWellFormed` is `true`.
190161
+ * - when `requireWellFormed` is `true`, `DOMException` with code `INVALID_STATE_ERR`
190162
+ * is only thrown to prevent injection vectors, not for all the spec mandated checks.
190163
+ *
190164
+ * @param {Node} node
190165
+ * @param {boolean} [isHtml]
190166
+ * @param {function} [nodeFilter]
190167
+ * @param {Object} [options]
190168
+ * @param {boolean} [options.requireWellFormed=false]
190169
+ * When `true`, throws for content that would produce ill-formed XML.
190170
+ * @returns {string}
190171
+ * @throws {DOMException}
190172
+ * With code `INVALID_STATE_ERR` when `requireWellFormed` is `true` and:
190173
+ * - an Element's qualified name (including any namespace prefix) is not a valid XML QName,
190174
+ * - an attribute's qualified name (including a synthesized `xmlns:` namespace declaration) is
190175
+ * not a valid XML QName,
190176
+ * - a CDATASection node's data contains `"]]>"`,
190177
+ * - a Comment node's data contains `"-->"` (bare `"--"` does not throw on this branch),
190178
+ * - a ProcessingInstruction's target is not a valid XML `NCName` (a `Name` with no colon) or is
190179
+ * an ASCII case-insensitive match for `"xml"`, or its data contains `"?>"`,
190180
+ * - a DocumentType's `name` is not a valid XML `Name` (XML 1.0 production [5]),
190181
+ * - a DocumentType's `publicId` is non-empty and does not match the XML `PubidLiteral`
190182
+ * production,
190183
+ * - a DocumentType's `systemId` is non-empty and does not match the XML `SystemLiteral`
190184
+ * production,
190185
+ * - a DocumentType's `internalSubset` contains `"]>"`, or
190186
+ * - an EntityReference's `nodeName` is not a valid XML `Name` (XML 1.0 production [5]).
190187
+ * Note: xmldom does not enforce `readonly` on DocumentType fields — direct property
190188
+ * writes succeed and are covered by the serializer-level checks above.
190189
+ * @see https://html.spec.whatwg.org/#dom-xmlserializer-serializetostring
190190
+ * @see https://w3c.github.io/DOM-Parsing/#xml-serialization
190191
+ * @see https://github.com/w3c/DOM-Parsing/issues/84
190192
+ */
190193
+ XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter,options){
190194
+ return nodeSerializeToString.call(node,isHtml,nodeFilter,options);
189462
190195
  };
189463
190196
  Node.prototype.toString = nodeSerializeToString;
189464
- function nodeSerializeToString(isHtml,nodeFilter){
190197
+ function nodeSerializeToString(isHtml,nodeFilter,options){
190198
+ var requireWellFormed = !!options && !!options.requireWellFormed;
189465
190199
  var buf = [];
189466
190200
  var refNode = this.nodeType == 9 && this.documentElement || this;
189467
190201
  var prefix = refNode.prefix;
@@ -189478,7 +190212,7 @@ function requireDom () {
189478
190212
  ];
189479
190213
  }
189480
190214
  }
189481
- serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces);
190215
+ serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces,requireWellFormed);
189482
190216
  //console.log('###',this.nodeType,uri,prefix,buf.join(''))
189483
190217
  return buf.join('');
189484
190218
  }
@@ -189523,275 +190257,350 @@ function requireDom () {
189523
190257
  * @see https://www.w3.org/TR/xml11/#AVNormalize
189524
190258
  * @see https://w3c.github.io/DOM-Parsing/#serializing-an-element-s-attributes
189525
190259
  */
189526
- function addSerializedAttribute(buf, qualifiedName, value) {
190260
+ function addSerializedAttribute(buf, qualifiedName, value, requireWellFormed) {
190261
+ if (requireWellFormed && !tagNamePattern.test(qualifiedName)) {
190262
+ throw new DOMException(INVALID_STATE_ERR, 'The attribute name "' + qualifiedName + '" is not a valid XML QName');
190263
+ }
189527
190264
  buf.push(' ', qualifiedName, '="', value.replace(/[<>&"\t\n\r]/g, _xmlEncoder), '"');
189528
190265
  }
189529
190266
 
189530
- function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
190267
+ function serializeToString(node, buf, isHTML, nodeFilter, visibleNamespaces, requireWellFormed) {
189531
190268
  if (!visibleNamespaces) {
189532
190269
  visibleNamespaces = [];
189533
190270
  }
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
190271
+ walkDOM(node, { ns: visibleNamespaces, isHTML: isHTML }, {
190272
+ enter: function (n, ctx) {
190273
+ var ns = ctx.ns;
190274
+ var html = ctx.isHTML;
190275
+
190276
+ if (nodeFilter) {
190277
+ n = nodeFilter(n);
190278
+ if (n) {
190279
+ if (typeof n == 'string') {
190280
+ buf.push(n);
190281
+ return null;
189574
190282
  }
190283
+ } else {
190284
+ return null;
189575
190285
  }
189576
190286
  }
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;
190287
+
190288
+ switch (n.nodeType) {
190289
+ case ELEMENT_NODE:
190290
+ var attrs = n.attributes;
190291
+ var len = attrs.length;
190292
+ var nodeName = n.tagName;
190293
+
190294
+ html = NAMESPACE.isHTML(n.namespaceURI) || html;
190295
+
190296
+ var prefixedNodeName = nodeName;
190297
+ if (!html && !n.prefix && n.namespaceURI) {
190298
+ var defaultNS;
190299
+ // lookup current default ns from `xmlns` attribute
190300
+ for (var ai = 0; ai < attrs.length; ai++) {
190301
+ if (attrs.item(ai).name === 'xmlns') {
190302
+ defaultNS = attrs.item(ai).value;
190303
+ break;
190304
+ }
190305
+ }
190306
+ if (!defaultNS) {
190307
+ // lookup current default ns in visibleNamespaces
190308
+ for (var nsi = ns.length - 1; nsi >= 0; nsi--) {
190309
+ var nsEntry = ns[nsi];
190310
+ if (nsEntry.prefix === '' && nsEntry.namespace === n.namespaceURI) {
190311
+ defaultNS = nsEntry.namespace;
190312
+ break;
190313
+ }
190314
+ }
190315
+ }
190316
+ if (defaultNS !== n.namespaceURI) {
190317
+ for (var nsi = ns.length - 1; nsi >= 0; nsi--) {
190318
+ var nsEntry = ns[nsi];
190319
+ if (nsEntry.namespace === n.namespaceURI) {
190320
+ if (nsEntry.prefix) {
190321
+ prefixedNodeName = nsEntry.prefix + ':' + nodeName;
190322
+ }
190323
+ break;
190324
+ }
190325
+ }
189583
190326
  }
189584
- break
189585
190327
  }
189586
- }
189587
- }
189588
- }
189589
190328
 
189590
- buf.push('<', prefixedNodeName);
190329
+ if (requireWellFormed && !tagNamePattern.test(prefixedNodeName)) {
190330
+ throw new DOMException(INVALID_STATE_ERR, 'The element name "' + prefixedNodeName + '" is not a valid XML QName');
190331
+ }
190332
+ buf.push('<', prefixedNodeName);
190333
+
190334
+ // Build a fresh namespace snapshot for this element's children.
190335
+ // The slice prevents sibling elements from inheriting each other's declarations.
190336
+ var childNs = ns.slice();
190337
+ for (var i = 0; i < len; i++) {
190338
+ var attr = attrs.item(i);
190339
+ if (attr.prefix == 'xmlns') {
190340
+ childNs.push({ prefix: attr.localName, namespace: attr.value });
190341
+ } else if (attr.nodeName == 'xmlns') {
190342
+ childNs.push({ prefix: '', namespace: attr.value });
190343
+ }
190344
+ }
189591
190345
 
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
- }
190346
+ for (var i = 0; i < len; i++) {
190347
+ var attr = attrs.item(i);
190348
+ if (needNamespaceDefine(attr, html, childNs)) {
190349
+ var attrPrefix = attr.prefix || '';
190350
+ var uri = attr.namespaceURI;
190351
+ addSerializedAttribute(buf, attrPrefix ? 'xmlns:' + attrPrefix : 'xmlns', uri, requireWellFormed);
190352
+ childNs.push({ prefix: attrPrefix, namespace: uri });
190353
+ }
190354
+ // Apply nodeFilter and serialize the attribute.
190355
+ var filteredAttr = nodeFilter ? nodeFilter(attr) : attr;
190356
+ if (filteredAttr) {
190357
+ if (typeof filteredAttr === 'string') {
190358
+ buf.push(filteredAttr);
190359
+ } else {
190360
+ addSerializedAttribute(buf, filteredAttr.name, filteredAttr.value, requireWellFormed);
190361
+ }
190362
+ }
190363
+ }
189601
190364
 
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
- }
190365
+ // add namespace for current node
190366
+ if (nodeName === prefixedNodeName && needNamespaceDefine(n, html, childNs)) {
190367
+ var nodePrefix = n.prefix || '';
190368
+ var uri = n.namespaceURI;
190369
+ addSerializedAttribute(buf, nodePrefix ? 'xmlns:' + nodePrefix : 'xmlns', uri, requireWellFormed);
190370
+ childNs.push({ prefix: nodePrefix, namespace: uri });
190371
+ }
189612
190372
 
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
- }
190373
+ var child = n.firstChild;
190374
+ if (child || html && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)) {
190375
+ buf.push('>');
190376
+ if (html && /^script$/i.test(nodeName)) {
190377
+ // Inline serialization for <script> children; return null to skip walkDOM descent.
190378
+ while (child) {
190379
+ if (child.data) {
190380
+ buf.push(child.data);
190381
+ } else {
190382
+ serializeToString(child, buf, html, nodeFilter, childNs.slice(), requireWellFormed);
190383
+ }
190384
+ child = child.nextSibling;
190385
+ }
190386
+ buf.push('</', nodeName, '>');
190387
+ return null;
190388
+ }
190389
+ // Return child context; walkDOM descends and exit emits the closing tag.
190390
+ return { ns: childNs, isHTML: html, tag: prefixedNodeName };
190391
+ } else {
190392
+ buf.push('/>');
190393
+ return null;
190394
+ }
189620
190395
 
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());
190396
+ case DOCUMENT_NODE:
190397
+ case DOCUMENT_FRAGMENT_NODE:
190398
+ // Descend into children; exit is a no-op (tag is null).
190399
+ return { ns: ns.slice(), isHTML: html, tag: null };
190400
+
190401
+ case ATTRIBUTE_NODE:
190402
+ addSerializedAttribute(buf, n.name, n.value, requireWellFormed);
190403
+ return null;
190404
+
190405
+ case TEXT_NODE:
190406
+ /**
190407
+ * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
190408
+ * except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section.
190409
+ * If they are needed elsewhere, they must be escaped using either numeric character references or the strings
190410
+ * `&amp;` and `&lt;` respectively.
190411
+ * The right angle bracket (>) may be represented using the string " &gt; ", and must, for compatibility,
190412
+ * be escaped using either `&gt;` or a character reference when it appears in the string `]]>` in content,
190413
+ * when that string is not marking the end of a CDATA section.
190414
+ *
190415
+ * In the content of elements, character data is any string of characters
190416
+ * which does not contain the start-delimiter of any markup
190417
+ * and does not include the CDATA-section-close delimiter, `]]>`.
190418
+ *
190419
+ * @see https://www.w3.org/TR/xml/#NT-CharData
190420
+ * @see https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node
190421
+ */
190422
+ buf.push(n.data.replace(/[<&>]/g, _xmlEncoder));
190423
+ return null;
190424
+
190425
+ case CDATA_SECTION_NODE:
190426
+ if (requireWellFormed && n.data.indexOf(']]>') !== -1) {
190427
+ throw new DOMException(INVALID_STATE_ERR, 'The CDATASection data contains "]]>"');
189630
190428
  }
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);
190429
+ buf.push('<![CDATA[', n.data.replace(/]]>/g, ']]]]><![CDATA[>'), ']]>');
190430
+ return null;
190431
+
190432
+ case COMMENT_NODE:
190433
+ if (requireWellFormed && n.data.indexOf('-->') !== -1) {
190434
+ throw new DOMException(INVALID_STATE_ERR, 'The comment node data contains "-->"');
190435
+ }
190436
+ buf.push('<!--', n.data, '-->');
190437
+ return null;
190438
+
190439
+ case DOCUMENT_TYPE_NODE:
190440
+ if (requireWellFormed) {
190441
+ if (!tagNamePattern.test(n.name)) {
190442
+ throw new DOMException(INVALID_STATE_ERR, 'The doctype name "' + n.name + '" is not a valid XML Name');
190443
+ }
190444
+ if (n.publicId && !/^("[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%']*"|'[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%'"]*')$/.test(n.publicId)) {
190445
+ throw new DOMException(INVALID_STATE_ERR, 'DocumentType publicId is not a valid PubidLiteral');
190446
+ }
190447
+ if (n.systemId && !/^("[^"]*"|'[^']*')$/.test(n.systemId)) {
190448
+ throw new DOMException(INVALID_STATE_ERR, 'DocumentType systemId is not a valid SystemLiteral');
190449
+ }
190450
+ if (n.internalSubset && n.internalSubset.indexOf(']>') !== -1) {
190451
+ throw new DOMException(INVALID_STATE_ERR, 'DocumentType internalSubset contains "]>"');
190452
+ }
190453
+ }
190454
+ var pubid = n.publicId;
190455
+ var sysid = n.systemId;
190456
+ buf.push('<!DOCTYPE ', n.name);
190457
+ if (pubid) {
190458
+ buf.push(' PUBLIC ', pubid);
190459
+ if (sysid && sysid != '.') {
190460
+ buf.push(' ', sysid);
190461
+ }
190462
+ buf.push('>');
190463
+ } else if (sysid && sysid != '.') {
190464
+ buf.push(' SYSTEM ', sysid, '>');
190465
+ } else {
190466
+ var sub = n.internalSubset;
190467
+ if (sub) {
190468
+ buf.push(' [', sub, ']');
190469
+ }
190470
+ buf.push('>');
190471
+ }
190472
+ return null;
190473
+
190474
+ case PROCESSING_INSTRUCTION_NODE:
190475
+ if (requireWellFormed) {
190476
+ if (!tagNamePattern.test(n.target) || n.target.indexOf(':') !== -1 || n.target.toLowerCase() === 'xml') {
190477
+ throw new DOMException(
190478
+ INVALID_STATE_ERR,
190479
+ 'The processing instruction target "' + n.target + '" is not a valid XML NCName or is reserved'
190480
+ );
190481
+ }
190482
+ if (n.data.indexOf('?>') !== -1) {
190483
+ throw new DOMException(INVALID_STATE_ERR, 'The ProcessingInstruction data contains "?>"');
190484
+ }
190485
+ }
190486
+ buf.push('<?', n.target, ' ', n.data, '?>');
190487
+ return null;
190488
+
190489
+ case ENTITY_REFERENCE_NODE:
190490
+ if (requireWellFormed && !tagNamePattern.test(n.nodeName)) {
190491
+ throw new DOMException(
190492
+ INVALID_STATE_ERR,
190493
+ 'The entity reference name "' + n.nodeName + '" is not a valid XML Name'
190494
+ );
190495
+ }
190496
+ buf.push('&', n.nodeName, ';');
190497
+ return null;
190498
+
190499
+ //case ENTITY_NODE:
190500
+ //case NOTATION_NODE:
190501
+ default:
190502
+ buf.push('??', n.nodeName);
190503
+ return null;
189689
190504
  }
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,"]");
190505
+ },
190506
+ exit: function (n, childCtx) {
190507
+ if (childCtx && childCtx.tag) {
190508
+ buf.push('</', childCtx.tag, '>');
189697
190509
  }
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
- }
190510
+ },
190511
+ });
189710
190512
  }
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;
190513
+ /**
190514
+ * Imports a node from a different document into `doc`, creating a new copy.
190515
+ * Delegates to {@link walkDOM} for traversal. Each node in the subtree is shallow-cloned,
190516
+ * stamped with `doc` as its `ownerDocument`, and detached (`parentNode` set to `null`).
190517
+ * Children are imported recursively when `deep` is `true`; for {@link Attr} nodes `deep` is
190518
+ * always forced to `true`
190519
+ * because an attribute's value lives in a child text node.
190520
+ *
190521
+ * @param {Document} doc
190522
+ * The document that will own the imported node.
190523
+ * @param {Node} node
190524
+ * The node to import.
190525
+ * @param {boolean} deep
190526
+ * If `true`, descendants are imported recursively.
190527
+ * @returns {Node}
190528
+ * The newly imported node, now owned by `doc`.
190529
+ */
190530
+ function importNode(doc, node, deep) {
190531
+ var destRoot;
190532
+ walkDOM(node, null, {
190533
+ enter: function (srcNode, destParent) {
190534
+ // Shallow-clone the node and stamp it into the target document.
190535
+ var destNode = srcNode.cloneNode(false);
190536
+ destNode.ownerDocument = doc;
190537
+ destNode.parentNode = null;
190538
+ // capture as the root of the imported subtree or attach to parent.
190539
+ if (destParent === null) {
190540
+ destRoot = destNode;
190541
+ } else {
190542
+ destParent.appendChild(destNode);
190543
+ }
190544
+ // ATTRIBUTE_NODE must always be imported deeply: its value lives in a child text node.
190545
+ var shouldDeep = srcNode.nodeType === ATTRIBUTE_NODE || deep;
190546
+ return shouldDeep ? destNode : null;
190547
+ },
190548
+ });
190549
+ return destRoot;
189755
190550
  }
189756
190551
  //
189757
190552
  //var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1,
189758
190553
  // 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;
190554
+ function cloneNode(doc, node, deep) {
190555
+ var destRoot;
190556
+ walkDOM(node, null, {
190557
+ enter: function (srcNode, destParent) {
190558
+ // 1. Create a blank node of the same type and copy all scalar own properties.
190559
+ var destNode = new srcNode.constructor();
190560
+ for (var n in srcNode) {
190561
+ if (Object.prototype.hasOwnProperty.call(srcNode, n)) {
190562
+ var v = srcNode[n];
190563
+ if (typeof v != 'object') {
190564
+ if (v != destNode[n]) {
190565
+ destNode[n] = v;
190566
+ }
190567
+ }
189767
190568
  }
189768
190569
  }
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;
190570
+ if (srcNode.childNodes) {
190571
+ destNode.childNodes = new NodeList();
190572
+ }
190573
+ destNode.ownerDocument = doc;
190574
+ // 2. Handle node-type-specific setup.
190575
+ // Attributes are not DOM children, so they are cloned inline here
190576
+ // rather than by walkDOM descent.
190577
+ // ATTRIBUTE_NODE forces deep=true so its own children are walked.
190578
+ var shouldDeep = deep;
190579
+ switch (destNode.nodeType) {
190580
+ case ELEMENT_NODE:
190581
+ var attrs = srcNode.attributes;
190582
+ var attrs2 = (destNode.attributes = new NamedNodeMap());
190583
+ var len = attrs.length;
190584
+ attrs2._ownerElement = destNode;
190585
+ for (var i = 0; i < len; i++) {
190586
+ destNode.setAttributeNode(cloneNode(doc, attrs.item(i), true));
190587
+ }
190588
+ break;
190589
+ case ATTRIBUTE_NODE:
190590
+ shouldDeep = true;
190591
+ }
190592
+ // 3. Attach to parent, or capture as the root of the cloned subtree.
190593
+ if (destParent !== null) {
190594
+ destParent.appendChild(destNode);
190595
+ } else {
190596
+ destRoot = destNode;
190597
+ }
190598
+ // 4. Return destNode as the context for children (causes walkDOM to descend),
190599
+ // or null to skip children (shallow clone).
190600
+ return shouldDeep ? destNode : null;
190601
+ },
190602
+ });
190603
+ return destRoot;
189795
190604
  }
189796
190605
 
189797
190606
  function __set__(object,key,value){
@@ -189807,49 +190616,55 @@ function requireDom () {
189807
190616
  }
189808
190617
  });
189809
190618
 
189810
- Object.defineProperty(Node.prototype,'textContent',{
189811
- get:function(){
189812
- return getTextContent(this);
190619
+ /**
190620
+ * The text content of this node and its descendants.
190621
+ *
190622
+ * Setting `textContent` on an element or document fragment replaces all child nodes with a
190623
+ * single text node; on other nodes it sets `data`, `value`, and `nodeValue` directly.
190624
+ *
190625
+ * @type {string | null}
190626
+ * @see {@link https://dom.spec.whatwg.org/#dom-node-textcontent}
190627
+ */
190628
+ Object.defineProperty(Node.prototype, 'textContent', {
190629
+ get: function () {
190630
+ if (this.nodeType === ELEMENT_NODE || this.nodeType === DOCUMENT_FRAGMENT_NODE) {
190631
+ var buf = [];
190632
+ walkDOM(this, null, {
190633
+ enter: function (n) {
190634
+ if (n.nodeType === ELEMENT_NODE || n.nodeType === DOCUMENT_FRAGMENT_NODE) {
190635
+ return true; // enter children
190636
+ }
190637
+ if (n.nodeType === PROCESSING_INSTRUCTION_NODE || n.nodeType === COMMENT_NODE) {
190638
+ return null; // excluded from text content
190639
+ }
190640
+ buf.push(n.nodeValue);
190641
+ },
190642
+ });
190643
+ return buf.join('');
190644
+ }
190645
+ return this.nodeValue;
189813
190646
  },
189814
190647
 
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;
190648
+ set: function (data) {
190649
+ switch (this.nodeType) {
190650
+ case ELEMENT_NODE:
190651
+ case DOCUMENT_FRAGMENT_NODE:
190652
+ while (this.firstChild) {
190653
+ this.removeChild(this.firstChild);
190654
+ }
190655
+ if (data || String(data)) {
190656
+ this.appendChild(this.ownerDocument.createTextNode(data));
190657
+ }
190658
+ break;
189826
190659
 
189827
- default:
189828
- this.data = data;
189829
- this.value = data;
189830
- this.nodeValue = data;
190660
+ default:
190661
+ this.data = data;
190662
+ this.value = data;
190663
+ this.nodeValue = data;
189831
190664
  }
189832
- }
190665
+ },
189833
190666
  });
189834
190667
 
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
190668
  __set__ = function(object,key,value){
189854
190669
  //console.log(value)
189855
190670
  object['$$'+key] = value;
@@ -189865,6 +190680,7 @@ function requireDom () {
189865
190680
  dom.Element = Element;
189866
190681
  dom.Node = Node;
189867
190682
  dom.NodeList = NodeList;
190683
+ dom.walkDOM = walkDOM;
189868
190684
  dom.XMLSerializer = XMLSerializer;
189869
190685
  //}
189870
190686
  return dom;
@@ -189879,7 +190695,7 @@ var hasRequiredEntities;
189879
190695
  function requireEntities () {
189880
190696
  if (hasRequiredEntities) return entities;
189881
190697
  hasRequiredEntities = 1;
189882
- (function (exports$1) {
190698
+ (function (exports) {
189883
190699
 
189884
190700
  var freeze = requireConventions().freeze;
189885
190701
 
@@ -189890,7 +190706,7 @@ function requireEntities () {
189890
190706
  * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-predefined-ent W3C XML 1.0
189891
190707
  * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML Wikipedia
189892
190708
  */
189893
- exports$1.XML_ENTITIES = freeze({
190709
+ exports.XML_ENTITIES = freeze({
189894
190710
  amp: '&',
189895
190711
  apos: "'",
189896
190712
  gt: '>',
@@ -189912,7 +190728,7 @@ function requireEntities () {
189912
190728
  * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML Wikipedia (HTML)
189913
190729
  * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML Wikpedia (XHTML)
189914
190730
  */
189915
- exports$1.HTML_ENTITIES = freeze({
190731
+ exports.HTML_ENTITIES = freeze({
189916
190732
  Aacute: '\u00C1',
189917
190733
  aacute: '\u00E1',
189918
190734
  Abreve: '\u0102',
@@ -192044,7 +192860,7 @@ function requireEntities () {
192044
192860
  * @deprecated use `HTML_ENTITIES` instead
192045
192861
  * @see HTML_ENTITIES
192046
192862
  */
192047
- exports$1.entityMap = exports$1.HTML_ENTITIES;
192863
+ exports.entityMap = exports.HTML_ENTITIES;
192048
192864
  } (entities));
192049
192865
  return entities;
192050
192866
  }
@@ -192057,14 +192873,8 @@ function requireSax () {
192057
192873
  if (hasRequiredSax) return sax;
192058
192874
  hasRequiredSax = 1;
192059
192875
  var NAMESPACE = requireConventions().NAMESPACE;
192876
+ var tagNamePattern = requireConventions().tagNamePattern;
192060
192877
 
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
192878
  //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
192879
 
192070
192880
  //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
@@ -192175,7 +192985,13 @@ function requireSax () {
192175
192985
  switch(source.charAt(tagStart+1)){
192176
192986
  case '/':
192177
192987
  var end = source.indexOf('>',tagStart+3);
192178
- var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, '');
192988
+ // Anchored trailing-whitespace trim. The former `/[ \t\n\r]+$/g` backtracked
192989
+ // quadratically on a name shaped `whitespace-run + non-whitespace char`
192990
+ // (an end tag `</ … x>`): from every start position it extended `[ws]+`
192991
+ // to the end and then failed the `$` anchor. This anchored form matches the
192992
+ // whole string once and captures everything up to the last non-whitespace
192993
+ // character, so it trims in linear time with byte-identical output.
192994
+ var tagName = source.substring(tagStart + 2, end).replace(/^([\s\S]*?[^ \t\n\r])?[ \t\n\r]*$/, '$1');
192179
192995
  var config = parseStack.pop();
192180
192996
  if(end<0){
192181
192997
 
@@ -192186,6 +193002,14 @@ function requireSax () {
192186
193002
  tagName = tagName.replace(/[\s<].*/,'');
192187
193003
  errorHandler.error("end tag name: "+tagName+' maybe not complete');
192188
193004
  end = tagStart+1+tagName.length;
193005
+ }else if(/[ \t\n\r]/.test(tagName) && tagNamePattern.test(tagName.split(/[ \t\n\r]/)[0])){
193006
+ // The XML `ETag` production is `'</' Name S? '>'`: only optional whitespace may follow
193007
+ // the `Name`. A valid `Name` followed by whitespace and non-whitespace residue (e.g.
193008
+ // `</a\nbogus>` or `</a bogus>`) is not well-formed, but historically it was silently
193009
+ // accepted (the malformed end tag ignored, the residue dropped, the element left on the
193010
+ // stack). Report it as a recoverable `error` (which a custom errorHandler may escalate to
193011
+ // fatal) while keeping the existing recovery so the parsed DOM stays byte-identical.
193012
+ errorHandler.error('end tag name is followed by whitespace and trailing content: "'+tagName+'"');
192189
193013
  }
192190
193014
  var localNSMap = config.localNSMap;
192191
193015
  var endMatch = config.tagName == tagName;
@@ -192309,6 +193133,15 @@ function requireSax () {
192309
193133
  var s = S_TAG;//status
192310
193134
  while(true){
192311
193135
  var c = source.charAt(p);
193136
+ if (s === S_TAG && c === '<') {
193137
+ // A `<` can never occur inside a tag name. Without this guard the scan runs
193138
+ // on to the next `>` (or EOF) before the tag name is rejected, so a document
193139
+ // with many `<` inside a malformed tag makes each one-character recovery step
193140
+ // re-scan to the distant `>` — O(n^2). Stopping at the `<` keeps each recovery
193141
+ // step bounded. The candidate scanned so far is reported raw, consistent with
193142
+ // the sibling invalid-tag-name throw below.
193143
+ throw new Error('unexpected < in tag name: ' + source.slice(start, p));
193144
+ }
192312
193145
  switch(c){
192313
193146
  case '=':
192314
193147
  if(s === S_ATTR){//attrName
@@ -192501,9 +193334,13 @@ function requireSax () {
192501
193334
  if(nsPrefix !== false){//hack!!
192502
193335
  if(localNSMap == null){
192503
193336
  localNSMap = {};
192504
- //console.log(currentNSMap,0)
192505
- _copy(currentNSMap,currentNSMap={});
192506
- //console.log(currentNSMap,1)
193337
+ // Derive the child scope's namespace map by prototype-chain inheritance
193338
+ // instead of a flat copy: lookups inherit ancestor prefixes transparently,
193339
+ // so a document nesting N scopes retains O(N) map entries rather than
193340
+ // sum(1..N) = O(N^2). localNSMap stays a flat own-only record of the
193341
+ // prefixes declared at THIS element, so own-property enumeration
193342
+ // (endPrefixMapping below) still reports only local declarations.
193343
+ currentNSMap = Object.create(currentNSMap);
192507
193344
  }
192508
193345
  currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
192509
193346
  a.uri = NAMESPACE.XMLNS;
@@ -192655,7 +193492,7 @@ function requireSax () {
192655
193492
  function parseInstruction(source,start,domBuilder){
192656
193493
  var end = source.indexOf('?>',start);
192657
193494
  if(end){
192658
- var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
193495
+ var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)$/);
192659
193496
  if(match){
192660
193497
  match[0].length;
192661
193498
  domBuilder.processingInstruction(match[1], match[2]) ;
@@ -193852,7 +194689,7 @@ var hasRequiredMoment;
193852
194689
  function requireMoment () {
193853
194690
  if (hasRequiredMoment) return moment$1.exports;
193854
194691
  hasRequiredMoment = 1;
193855
- (function (module, exports$1) {
194692
+ (function (module, exports) {
193856
194693
  (function (global, factory) {
193857
194694
  module.exports = factory() ;
193858
194695
  }(this, (function () {
@@ -199542,7 +200379,7 @@ function requireMomentTimezone () {
199542
200379
  hasRequiredMomentTimezone = 1;
199543
200380
  (function (module) {
199544
200381
  //! moment-timezone.js
199545
- //! version : 0.6.0
200382
+ //! version : 0.6.4
199546
200383
  //! Copyright (c) JS Foundation and other contributors
199547
200384
  //! license : MIT
199548
200385
  //! github.com/moment/moment-timezone
@@ -199568,12 +200405,18 @@ function requireMomentTimezone () {
199568
200405
  // return moment;
199569
200406
  // }
199570
200407
 
199571
- var VERSION = "0.6.0",
200408
+ var VERSION = "0.6.4",
199572
200409
  zones = {},
199573
200410
  links = {},
199574
200411
  countries = {},
199575
200412
  names = {},
199576
200413
  guesses = {},
200414
+ parsingInZone = false,
200415
+ parsingNow,
200416
+ parsingNowFunction,
200417
+ hasParsingNow = false,
200418
+ ignoreDefaultZoneForInput,
200419
+ hasIgnoredDefaultZoneInput = false,
199577
200420
  cachedGuess;
199578
200421
 
199579
200422
  if (!moment || typeof moment.version !== 'string') {
@@ -199745,17 +200588,16 @@ function requireMomentTimezone () {
199745
200588
  offsets = this.offsets,
199746
200589
  untils = this.untils,
199747
200590
  max = untils.length - 1,
199748
- offset, offsetNext, offsetPrev, i;
200591
+ offset, offsetNext, i;
199749
200592
 
199750
200593
  for (i = 0; i < max; i++) {
199751
200594
  offset = offsets[i];
199752
200595
  offsetNext = offsets[i + 1];
199753
- offsetPrev = offsets[i ? i - 1 : i];
199754
200596
 
199755
200597
  if (offset < offsetNext && tz.moveAmbiguousForward) {
199756
200598
  offset = offsetNext;
199757
- } else if (offset > offsetPrev && tz.moveInvalidForward) {
199758
- offset = offsetPrev;
200599
+ } else if (offset > offsetNext && tz.moveInvalidForward) {
200600
+ offset = offsetNext;
199759
200601
  }
199760
200602
 
199761
200603
  if (target < untils[i] - (offset * 60000)) {
@@ -199780,6 +200622,15 @@ function requireMomentTimezone () {
199780
200622
  }
199781
200623
  };
199782
200624
 
200625
+ var utcDefaultZone = new Zone();
200626
+ utcDefaultZone._set({
200627
+ name : 'UTC',
200628
+ abbrs : ['UTC'],
200629
+ untils : [Infinity],
200630
+ offsets : [0],
200631
+ population : 0
200632
+ });
200633
+
199783
200634
  /************************************
199784
200635
  Country object
199785
200636
  ************************************/
@@ -200117,6 +200968,85 @@ function requireMomentTimezone () {
200117
200968
  return !!(m._a && (m._tzm === undefined) && !isUnixTimestamp);
200118
200969
  }
200119
200970
 
200971
+ function isObjectInput (input) {
200972
+ var prop;
200973
+
200974
+ if (moment.isMoment(input) || input === null || Object.prototype.toString.call(input) !== '[object Object]') {
200975
+ return false;
200976
+ }
200977
+ if (Object.getOwnPropertyNames) {
200978
+ return Object.getOwnPropertyNames(input).length > 0;
200979
+ }
200980
+ for (prop in input) {
200981
+ if (Object.prototype.hasOwnProperty.call(input, prop)) {
200982
+ return true;
200983
+ }
200984
+ }
200985
+ return false;
200986
+ }
200987
+
200988
+ function parseWithZoneNow (args, name, stringInput) {
200989
+ var savedNow = moment.now,
200990
+ savedDefaultZone = moment.defaultZone,
200991
+ savedParsingInZone = parsingInZone,
200992
+ savedParsingNow = parsingNow,
200993
+ savedParsingNowFunction = parsingNowFunction,
200994
+ savedHasParsingNow = hasParsingNow,
200995
+ now,
200996
+ hasNow = false,
200997
+ zonedNow,
200998
+ wallNow,
200999
+ parsedDateParts,
201000
+ out;
201001
+
201002
+ if (!parsingInZone) {
201003
+ parsingNow = undefined;
201004
+ parsingNowFunction = savedNow;
201005
+ hasParsingNow = false;
201006
+ }
201007
+ parsingInZone = true;
201008
+ moment.now = function () {
201009
+ if (!hasNow) {
201010
+ if (!hasParsingNow) {
201011
+ parsingNow = parsingNowFunction.call(moment);
201012
+ hasParsingNow = true;
201013
+ }
201014
+ now = parsingNow;
201015
+ hasNow = true;
201016
+ zonedNow = moment.tz(now, name);
201017
+ wallNow = zonedNow.valueOf() + zonedNow.utcOffset() * 60000;
201018
+ }
201019
+ return wallNow;
201020
+ };
201021
+ if (stringInput) {
201022
+ moment.defaultZone = utcDefaultZone;
201023
+ }
201024
+ try {
201025
+ out = moment.utc.apply(null, args);
201026
+ if (stringInput && hasNow && out._a && out._tzm !== undefined) {
201027
+ parsedDateParts = out.parsingFlags().parsedDateParts;
201028
+ if (!parsedDateParts || parsedDateParts[0] == null || parsedDateParts[1] == null || parsedDateParts[2] == null) {
201029
+ moment.now = function () {
201030
+ return now;
201031
+ };
201032
+ moment.defaultZone = savedDefaultZone;
201033
+ out = moment.utc.apply(null, args);
201034
+ }
201035
+ }
201036
+ } finally {
201037
+ moment.now = savedNow;
201038
+ moment.defaultZone = savedDefaultZone;
201039
+ parsingInZone = savedParsingInZone;
201040
+ if (!savedParsingInZone) {
201041
+ parsingNow = savedParsingNow;
201042
+ parsingNowFunction = savedParsingNowFunction;
201043
+ hasParsingNow = savedHasParsingNow;
201044
+ }
201045
+ }
201046
+
201047
+ return out;
201048
+ }
201049
+
200120
201050
  function logError (message) {
200121
201051
  if (typeof console !== 'undefined' && typeof console.error === 'function') {
200122
201052
  console.error(message);
@@ -200130,10 +201060,13 @@ function requireMomentTimezone () {
200130
201060
  function tz (input) {
200131
201061
  var args = Array.prototype.slice.call(arguments, 0, -1),
200132
201062
  name = arguments[arguments.length - 1],
200133
- out = moment.utc.apply(null, args),
200134
- zone;
201063
+ objectInput = isObjectInput(input),
201064
+ stringInput = args.length > 0 && typeof input === 'string',
201065
+ zone = objectInput || stringInput ? getZone(name) : null,
201066
+ out = objectInput && zone ? parseWithZoneNow(args, name) :
201067
+ stringInput && zone ? parseWithZoneNow(args, name, true) : moment.utc.apply(null, args);
200135
201068
 
200136
- if (!moment.isMoment(input) && needsOffset(out) && (zone = getZone(name))) {
201069
+ if (!moment.isMoment(input) && needsOffset(out) && (zone || (!objectInput && (zone = getZone(name))))) {
200137
201070
  out.add(zone.parse(out), 'minutes');
200138
201071
  }
200139
201072
 
@@ -200173,10 +201106,49 @@ function requireMomentTimezone () {
200173
201106
  moment.tz = tz;
200174
201107
 
200175
201108
  moment.defaultZone = null;
201109
+ var momentGetDefaultDateParts = moment._getDefaultDateParts;
201110
+ if (momentGetDefaultDateParts) {
201111
+ moment._getDefaultDateParts = function (config, now, forWeek) {
201112
+ var zone = moment.defaultZone,
201113
+ zonedNow,
201114
+ dateParts,
201115
+ savedIgnoredInput,
201116
+ savedHasIgnoredInput;
201117
+ forWeek = forWeek || config._isDefaultDatePartsForWeek;
201118
+
201119
+ if (parsingInZone && config._tzm === undefined) {
201120
+ zonedNow = new Date(now);
201121
+ return [zonedNow.getUTCFullYear(), zonedNow.getUTCMonth(), zonedNow.getUTCDate()];
201122
+ }
201123
+
201124
+ if (zone && !config._useUTC && config._tzm === undefined) {
201125
+ zonedNow = new Date(now - zone.utcOffset(now) * 60000);
201126
+ return [zonedNow.getUTCFullYear(), zonedNow.getUTCMonth(), zonedNow.getUTCDate()];
201127
+ }
201128
+
201129
+ if (forWeek && (config._useUTC || config._tzm !== undefined)) {
201130
+ savedIgnoredInput = ignoreDefaultZoneForInput;
201131
+ savedHasIgnoredInput = hasIgnoredDefaultZoneInput;
201132
+ ignoreDefaultZoneForInput = now;
201133
+ hasIgnoredDefaultZoneInput = true;
201134
+ try {
201135
+ dateParts = momentGetDefaultDateParts.call(this, config, now, forWeek);
201136
+ } finally {
201137
+ ignoreDefaultZoneForInput = savedIgnoredInput;
201138
+ hasIgnoredDefaultZoneInput = savedHasIgnoredInput;
201139
+ }
201140
+ return dateParts;
201141
+ }
201142
+
201143
+ return momentGetDefaultDateParts.call(this, config, now, forWeek);
201144
+ };
201145
+ }
200176
201146
 
200177
201147
  moment.updateOffset = function (mom, keepTime) {
200178
- var zone = moment.defaultZone,
200179
- offset;
201148
+ var zone = hasIgnoredDefaultZoneInput && ignoreDefaultZoneForInput === mom._i ? null : moment.defaultZone,
201149
+ offset,
201150
+ localTimestamp,
201151
+ normalizedTimestamp;
200180
201152
 
200181
201153
  if (mom._z === undefined) {
200182
201154
  if (zone && needsOffset(mom) && !mom._isUTC && mom.isValid()) {
@@ -200187,6 +201159,20 @@ function requireMomentTimezone () {
200187
201159
  }
200188
201160
  if (mom._z) {
200189
201161
  offset = mom._z.utcOffset(mom);
201162
+ if (keepTime) {
201163
+ // Resolve local times inside a forward gap using the configured
201164
+ // invalid-input policy before applying the new offset.
201165
+ localTimestamp = mom._d.valueOf();
201166
+ if (!mom._isUTC) {
201167
+ localTimestamp -= mom._d.getTimezoneOffset() * 60000;
201168
+ }
201169
+ if (mom._z.utcOffset(localTimestamp + offset * 60000) !== offset) {
201170
+ offset = mom._z.parse(localTimestamp);
201171
+ localTimestamp += offset * 60000;
201172
+ offset = mom._z.utcOffset(localTimestamp);
201173
+ normalizedTimestamp = localTimestamp - offset * 60000;
201174
+ }
201175
+ }
200190
201176
  if (Math.abs(offset) < 16) {
200191
201177
  offset = offset / 60;
200192
201178
  }
@@ -200197,6 +201183,9 @@ function requireMomentTimezone () {
200197
201183
  } else {
200198
201184
  mom.zone(offset, keepTime);
200199
201185
  }
201186
+ if (normalizedTimestamp != null) {
201187
+ mom._d.setTime(normalizedTimestamp);
201188
+ }
200200
201189
  }
200201
201190
  };
200202
201191
 
@@ -203064,11 +204053,11 @@ var DEFAULT_FORMATS;
203064
204053
  DEFAULT_FORMATS["DATE_TIME"] = "yyyy-MM-dd HH:mm:ss";
203065
204054
  })(DEFAULT_FORMATS || (DEFAULT_FORMATS = {}));
203066
204055
 
203067
- const $RAF = window.requestAnimationFrame;
204056
+ const $RAF$1 = window.requestAnimationFrame;
203068
204057
  const $RAFQueue = [];
203069
204058
  const invokeLater = fn => {
203070
204059
  if (!$RAFQueue.length) {
203071
- $RAF(() => {
204060
+ $RAF$1(() => {
203072
204061
  $RAFQueue.forEach(f => f());
203073
204062
  $RAFQueue.length = 0;
203074
204063
  });
@@ -203610,220 +204599,70 @@ const getFnForEventExpr = (expr) => {
203610
204599
  return fnExecutor(expr, ExpressionType.Action);
203611
204600
  };
203612
204601
 
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
204602
  const registry = new Map();
203619
204603
  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
- */
204604
+ const FIRST_TIME_WATCH = {};
204605
+ Object.freeze(FIRST_TIME_WATCH);
203644
204606
  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);
204607
+ let data = newVal, formattedData;
204608
+ if (isArray(data)) {
204609
+ formattedData = data.map(function (datum) {
204610
+ return findValueOf(datum, restExpr);
204611
+ });
204612
+ // If resulting structure is an array of array, flatten it
204613
+ if (isArray(formattedData[0])) {
204614
+ formattedData = flatten(formattedData);
204615
+ }
204616
+ listenerFn(formattedData, oldVal);
203652
204617
  }
203653
- listenerFn(formattedData, oldVal);
203654
204618
  };
203655
- /**
203656
- * Updates watch info for array expressions
203657
- */
203658
- const getUpdatedWatchInfo = (expr, acceptsArray, listener) => {
203659
- const regex = /\[\$i\]/g;
204619
+ const getUpdatedWatcInfo = (expr, acceptsArray, listener) => {
204620
+ // listener doesn't accept array
204621
+ // replace all `[$i]` with `[0]` and return the expression
204622
+ let regex = /\[\$i\]/g, $I = '[$i]', $0 = '[0]';
203660
204623
  if (!acceptsArray) {
203661
204624
  return {
203662
- expr: expr.replace(regex, ARRAY_INDEX_ZERO),
203663
- listener
204625
+ 'expr': expr.replace(regex, $0),
204626
+ 'listener': listener
203664
204627
  };
203665
204628
  }
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;
204629
+ // listener accepts array
204630
+ // replace all except the last `[$i]` with `[0]` and return the expression.
204631
+ var index = expr.lastIndexOf($I), _expr = expr.substr(0, index).replace($I, $0), restExpr = expr.substr(index + 5), arrayConsumerFn = listener;
204632
+ if (restExpr) {
204633
+ arrayConsumerFn = arrayConsumer.bind(undefined, listener, restExpr);
204634
+ }
203672
204635
  return {
203673
- expr: baseExpr,
203674
- listener: arrayConsumerFn
204636
+ 'expr': _expr,
204637
+ 'listener': arrayConsumerFn
203675
204638
  };
203676
204639
  };
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
204640
  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);
204641
+ if (expr.indexOf('[$i]') !== -1) {
204642
+ let watchInfo = getUpdatedWatcInfo(expr, config && (config.arrayType || config.isList), listener);
203747
204643
  expr = watchInfo.expr;
203748
204644
  listener = watchInfo.listener;
203749
204645
  }
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
204646
  const fn = $parseExpr();
203764
- const scopeType = getScopeType($scope);
203765
- const scopeName = getScopeName($scope, scopeType);
203766
- const watchInfo = {
203767
- fn: fn.bind(null, $scope, $locals),
204647
+ registry.set(identifier, {
204648
+ fn: fn.bind(expr, $scope, $locals),
203768
204649
  listener,
203769
204650
  expr,
203770
204651
  last: FIRST_TIME_WATCH,
203771
204652
  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
- }
204653
+ isMuted: isMuted
204654
+ });
203789
204655
  return () => $unwatch(identifier);
203790
204656
  };
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
- };
204657
+ const $unwatch = identifier => registry.delete(identifier);
204658
+ window.watchRegistry = registry;
203818
204659
  const $appDigest = (() => {
203819
- return (force = false) => {
204660
+ return (force) => {
203820
204661
  {
203821
204662
  return;
203822
204663
  }
203823
204664
  };
203824
204665
  })();
203825
- // Export registry for debugging
203826
- // (window as any).watchRegistry = registry;
203827
204666
 
203828
204667
  var ComponentType;
203829
204668
  (function (ComponentType) {
@@ -203879,8 +204718,6 @@ var Operation;
203879
204718
  const DataSource = {
203880
204719
  Operation
203881
204720
  };
203882
- class App {
203883
- }
203884
204721
  class AbstractI18nService {
203885
204722
  }
203886
204723
 
@@ -203898,7 +204735,6 @@ const REGEX = {
203898
204735
  SUPPORTED_AUDIO_FORMAT: /\.(mp3|ogg|webm|wma|3gp|wav|m4a)$/i,
203899
204736
  SUPPORTED_VIDEO_FORMAT: /\.(mp4|ogg|webm|wmv|mpeg|mpg|avi|mov)$/i,
203900
204737
  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
204738
  REPLACE_PATTERN: /\$\{([^\}]+)\}/g,
203903
204739
  DATA_URL: /^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*)\s*$/i,
203904
204740
  ISO_DATE_FORMAT: /(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})(\.\d+)?([+-]\d{2}:?\d{2}|Z)$/
@@ -204121,9 +204957,6 @@ const isVideoFile = (fileName) => {
204121
204957
  const isValidWebURL = (url) => {
204122
204958
  return (REGEX.VALID_WEB_URL).test(url);
204123
204959
  };
204124
- const isValidImageUrl = (url) => {
204125
- return (REGEX.VALID_IMAGE_URL).test(url?.trim());
204126
- };
204127
204960
  /*This function returns the url to the resource after checking the validity of url*/
204128
204961
  const getResourceURL = (urlString) => {
204129
204962
  return urlString;
@@ -205377,7 +206210,6 @@ var Utils = /*#__PURE__*/Object.freeze({
205377
206210
  isPageable: isPageable,
205378
206211
  isSafari: isSafari,
205379
206212
  isTablet: isTablet,
205380
- isValidImageUrl: isValidImageUrl,
205381
206213
  isValidWebURL: isValidWebURL,
205382
206214
  isVideoFile: isVideoFile,
205383
206215
  loadScript: loadScript,
@@ -208217,7 +209049,7 @@ class PipeProvider {
208217
209049
  this.preparePipeMeta(CurrencyPipe$1, 'currency', true, [this._locale]),
208218
209050
  this.preparePipeMeta(DatePipe$1, 'date', true, [this._locale]),
208219
209051
  this.preparePipeMeta(ToDatePipe, 'toDate', true, [
208220
- new DatePipe$1(this._locale), undefined, this.injector.get(App), this.injector.get(CustomPipeManager)
209052
+ new DatePipe$1(this._locale), undefined, this.injector.get(CustomPipeManager)
208221
209053
  ]),
208222
209054
  this.preparePipeMeta(ToNumberPipe, 'toNumber', true, [
208223
209055
  new DecimalPipe$1(this._locale),
@@ -208234,7 +209066,7 @@ class PipeProvider {
208234
209066
  new DecimalPipe$1(this._locale)
208235
209067
  ]),
208236
209068
  this.preparePipeMeta(StringToNumberPipe, 'stringToNumber', true),
208237
- this.preparePipeMeta(CustomPipe, 'custom', true, [this.injector.get(App), this.injector.get(CustomPipeManager)]),
209069
+ this.preparePipeMeta(CustomPipe, 'custom', true, [this.injector.get(CustomPipeManager)]),
208238
209070
  this.preparePipeMeta(TrustAsPipe, 'trustAs', true, [this.domSanitizer]),
208239
209071
  this.preparePipeMeta(SanitizePipe, 'sanitize', true, [this.domSanitizer]),
208240
209072
  this.preparePipeMeta(TemplateReplacePipe, 'templateReplace', true),