@wavemaker/angular-codegen 11.14.1-27.647700 → 11.14.1-28.647720

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.
@@ -131422,6 +131422,13 @@ function requireDom$1 () {
131422
131422
  * used for attributes or DocumentType entities
131423
131423
  */
131424
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);
131425
131432
  }
131426
131433
  function _findNodeIndex(list,node){
131427
131434
  var i = list.length;
@@ -131430,12 +131437,27 @@ function requireDom$1 () {
131430
131437
  }
131431
131438
  }
131432
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
+
131433
131451
  function _addNamedNode(el,list,newAttr,oldAttr){
131434
131452
  if(oldAttr){
131435
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);
131436
131457
  }else {
131437
131458
  list[list.length++] = newAttr;
131438
131459
  }
131460
+ _nnmIndexAdd(list, newAttr);
131439
131461
  if(el){
131440
131462
  newAttr.ownerElement = el;
131441
131463
  var doc = el.ownerDocument;
@@ -131454,6 +131476,7 @@ function requireDom$1 () {
131454
131476
  list[i] = list[++i];
131455
131477
  }
131456
131478
  list.length = lastIndex;
131479
+ _nnmIndexRemove(list, attr);
131457
131480
  if(el){
131458
131481
  var doc = el.ownerDocument;
131459
131482
  if(doc){
@@ -131487,7 +131510,11 @@ function requireDom$1 () {
131487
131510
  if(el && el!=this._ownerElement){
131488
131511
  throw new DOMException(INUSE_ATTRIBUTE_ERR);
131489
131512
  }
131490
- 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];
131491
131518
  _addNamedNode(this._ownerElement,this,attr,oldAttr);
131492
131519
  return oldAttr;
131493
131520
  },
@@ -131720,9 +131747,38 @@ function requireDom$1 () {
131720
131747
  while (child) {
131721
131748
  var next = child.nextSibling;
131722
131749
  if (next !== null && next.nodeType === TEXT_NODE && child.nodeType === TEXT_NODE) {
131723
- node.removeChild(next);
131724
- child.appendData(next.data);
131725
- // Do not advance child: re-check new nextSibling for another text run
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;
131726
131782
  } else {
131727
131783
  child = next;
131728
131784
  }
@@ -132533,8 +132589,10 @@ function requireDom$1 () {
132533
132589
  * - it does not do any input validation on the arguments and doesn't throw "InvalidCharacterError".
132534
132590
  *
132535
132591
  * Note: When the resulting document is serialized with `requireWellFormed: true`, the
132536
- * serializer throws with code `INVALID_STATE_ERR` if `.data` contains `?>` (W3C DOM Parsing
132537
- * §3.2.1.7). Without that option the data is emitted verbatim.
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.
132538
132596
  *
132539
132597
  * @param {string} target
132540
132598
  * @param {string} data
@@ -132559,7 +132617,27 @@ function requireDom$1 () {
132559
132617
  node.specified = true;
132560
132618
  return node;
132561
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
+ */
132562
132637
  createEntityReference : function(name){
132638
+ if (!tagNamePattern.test(name)) {
132639
+ throw new DOMException(INVALID_CHARACTER_ERR, 'not a valid xml name "' + name + '"');
132640
+ }
132563
132641
  var node = new EntityReference();
132564
132642
  node.ownerDocument = this;
132565
132643
  node.nodeName = name;
@@ -132771,15 +132849,16 @@ function requireDom$1 () {
132771
132849
  /**
132772
132850
  * Represents a DocumentType node (the `<!DOCTYPE ...>` declaration).
132773
132851
  *
132774
- * `publicId`, `systemId`, and `internalSubset` are plain own-property assignments.
132852
+ * `name`, `publicId`, `systemId`, and `internalSubset` are plain own-property assignments.
132775
132853
  * xmldom does not enforce the `readonly` constraint declared by the WHATWG DOM spec —
132776
132854
  * direct property writes succeed silently. Values are serialized verbatim when
132777
132855
  * `requireWellFormed` is false (the default). When the serializer is invoked with
132778
132856
  * `requireWellFormed: true` (via the 4th-parameter options object), it validates each
132779
- * field and throws `DOMException` with code `INVALID_STATE_ERR` on invalid values.
132857
+ * field — including `name`, which is checked against the XML `Name` production — and throws
132858
+ * `DOMException` with code `INVALID_STATE_ERR` on invalid values.
132780
132859
  *
132781
132860
  * @class
132782
- * @see https://developer.mozilla.org/en-US/docs/Web/API/DocumentType MDN
132861
+ * @see https://developer.mozilla.org/docs/Web/API/DocumentType MDN
132783
132862
  */
132784
132863
  function DocumentType() {
132785
132864
  } DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
@@ -132793,6 +132872,20 @@ function requireDom$1 () {
132793
132872
  } Entity.prototype.nodeType = ENTITY_NODE;
132794
132873
  _extends(Entity,Node);
132795
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
+ */
132796
132889
  function EntityReference() {
132797
132890
  } EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
132798
132891
  _extends(EntityReference,Node);
@@ -132835,12 +132928,15 @@ function requireDom$1 () {
132835
132928
  * not a valid XML QName,
132836
132929
  * - a CDATASection node's data contains `"]]>"`,
132837
132930
  * - a Comment node's data contains `"-->"` (bare `"--"` does not throw on this branch),
132838
- * - a ProcessingInstruction's data contains `"?>"`,
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]),
132839
132934
  * - a DocumentType's `publicId` is non-empty and does not match the XML `PubidLiteral`
132840
132935
  * production,
132841
132936
  * - a DocumentType's `systemId` is non-empty and does not match the XML `SystemLiteral`
132842
- * production, or
132843
- * - a DocumentType's `internalSubset` contains `"]>"`.
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]).
132844
132940
  * Note: xmldom does not enforce `readonly` on DocumentType fields — direct property
132845
132941
  * writes succeed and are covered by the serializer-level checks above.
132846
132942
  * @see https://html.spec.whatwg.org/#dom-xmlserializer-serializetostring
@@ -133095,6 +133191,9 @@ function requireDom$1 () {
133095
133191
 
133096
133192
  case DOCUMENT_TYPE_NODE:
133097
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
+ }
133098
133197
  if (n.publicId && !/^("[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%']*"|'[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%'"]*')$/.test(n.publicId)) {
133099
133198
  throw new DOMException(INVALID_STATE_ERR, 'DocumentType publicId is not a valid PubidLiteral');
133100
133199
  }
@@ -133126,13 +133225,27 @@ function requireDom$1 () {
133126
133225
  return null;
133127
133226
 
133128
133227
  case PROCESSING_INSTRUCTION_NODE:
133129
- if (requireWellFormed && n.data.indexOf('?>') !== -1) {
133130
- throw new DOMException(INVALID_STATE_ERR, 'The ProcessingInstruction data contains "?>"');
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
+ }
133131
133238
  }
133132
133239
  buf.push('<?', n.target, ' ', n.data, '?>');
133133
133240
  return null;
133134
133241
 
133135
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
+ }
133136
133249
  buf.push('&', n.nodeName, ';');
133137
133250
  return null;
133138
133251
 
@@ -135625,7 +135738,13 @@ function requireSax$1 () {
135625
135738
  switch(source.charAt(tagStart+1)){
135626
135739
  case '/':
135627
135740
  var end = source.indexOf('>',tagStart+3);
135628
- 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');
135629
135748
  var config = parseStack.pop();
135630
135749
  if(end<0){
135631
135750
 
@@ -135636,6 +135755,14 @@ function requireSax$1 () {
135636
135755
  tagName = tagName.replace(/[\s<].*/,'');
135637
135756
  errorHandler.error("end tag name: "+tagName+' maybe not complete');
135638
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+'"');
135639
135766
  }
135640
135767
  var localNSMap = config.localNSMap;
135641
135768
  var endMatch = config.tagName == tagName;
@@ -135759,6 +135886,15 @@ function requireSax$1 () {
135759
135886
  var s = S_TAG;//status
135760
135887
  while(true){
135761
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
+ }
135762
135898
  switch(c){
135763
135899
  case '=':
135764
135900
  if(s === S_ATTR){//attrName
@@ -135951,9 +136087,13 @@ function requireSax$1 () {
135951
136087
  if(nsPrefix !== false){//hack!!
135952
136088
  if(localNSMap == null){
135953
136089
  localNSMap = {};
135954
- //console.log(currentNSMap,0)
135955
- _copy(currentNSMap,currentNSMap={});
135956
- //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);
135957
136097
  }
135958
136098
  currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
135959
136099
  a.uri = NAMESPACE.XMLNS;
@@ -188377,6 +188517,13 @@ function requireDom () {
188377
188517
  * used for attributes or DocumentType entities
188378
188518
  */
188379
188519
  function NamedNodeMap() {
188520
+ // nodeName -> Attr membership index; lets the parse-time de-duplication in
188521
+ // setNamedItem resolve an existing attribute in O(1) instead of scanning the
188522
+ // list, so building an element with M attributes costs O(M) rather than O(M^2).
188523
+ // The numbered entries and length remain the sole authority for attribute order.
188524
+ // Object.create(null) so an attribute named __proto__ or constructor is an
188525
+ // ordinary key.
188526
+ this._nameIndex = Object.create(null);
188380
188527
  }
188381
188528
  function _findNodeIndex(list,node){
188382
188529
  var i = list.length;
@@ -188385,12 +188532,27 @@ function requireDom () {
188385
188532
  }
188386
188533
  }
188387
188534
 
188535
+ function _nnmIndexAdd(list, attr) {
188536
+ list._nameIndex[attr.nodeName] = attr;
188537
+ }
188538
+ function _nnmIndexRemove(list, attr) {
188539
+ // Only drop the entry if it still points at this attribute; a replacement with
188540
+ // a different nodeName may already have re-keyed it.
188541
+ if (list._nameIndex[attr.nodeName] === attr) {
188542
+ delete list._nameIndex[attr.nodeName];
188543
+ }
188544
+ }
188545
+
188388
188546
  function _addNamedNode(el,list,newAttr,oldAttr){
188389
188547
  if(oldAttr){
188390
188548
  list[_findNodeIndex(list,oldAttr)] = newAttr;
188549
+ // oldAttr leaves the list; drop its index entry (its nodeName may differ
188550
+ // from newAttr's when the replacement came via setNamedItemNS).
188551
+ _nnmIndexRemove(list, oldAttr);
188391
188552
  }else {
188392
188553
  list[list.length++] = newAttr;
188393
188554
  }
188555
+ _nnmIndexAdd(list, newAttr);
188394
188556
  if(el){
188395
188557
  newAttr.ownerElement = el;
188396
188558
  var doc = el.ownerDocument;
@@ -188409,6 +188571,7 @@ function requireDom () {
188409
188571
  list[i] = list[++i];
188410
188572
  }
188411
188573
  list.length = lastIndex;
188574
+ _nnmIndexRemove(list, attr);
188412
188575
  if(el){
188413
188576
  var doc = el.ownerDocument;
188414
188577
  if(doc){
@@ -188442,7 +188605,11 @@ function requireDom () {
188442
188605
  if(el && el!=this._ownerElement){
188443
188606
  throw new DOMException(INUSE_ATTRIBUTE_ERR);
188444
188607
  }
188445
- var oldAttr = this.getNamedItem(attr.nodeName);
188608
+ // Resolve any existing attribute with the same nodeName through the O(1)
188609
+ // membership index rather than an O(M) scan — this is the parse-dedup hot
188610
+ // path (setAttributeNode per attribute during parse). Absent -> undefined,
188611
+ // matching getNamedItem's contract.
188612
+ var oldAttr = this._nameIndex[attr.nodeName];
188446
188613
  _addNamedNode(this._ownerElement,this,attr,oldAttr);
188447
188614
  return oldAttr;
188448
188615
  },
@@ -188675,9 +188842,38 @@ function requireDom () {
188675
188842
  while (child) {
188676
188843
  var next = child.nextSibling;
188677
188844
  if (next !== null && next.nodeType === TEXT_NODE && child.nodeType === TEXT_NODE) {
188678
- node.removeChild(next);
188679
- child.appendData(next.data);
188680
- // Do not advance child: re-check new nextSibling for another text run
188845
+ // Merge the whole run of adjacent text nodes at once: gather the
188846
+ // following text siblings' data, unlink them in a single pass, and
188847
+ // re-index the child list a single time. Per-sibling `removeChild`
188848
+ // (each an O(K) re-index) plus per-sibling `appendData` (each an O(K)
188849
+ // string rebuild) is O(K^2) over a long run of single-character text
188850
+ // nodes; this keeps it O(K). The first text node of the run survives
188851
+ // and carries the concatenated data, preserving node identity and
188852
+ // locator semantics.
188853
+ var tail = [];
188854
+ var sibling = next;
188855
+ while (sibling !== null && sibling.nodeType === TEXT_NODE) {
188856
+ tail.push(sibling.data);
188857
+ sibling = sibling.nextSibling;
188858
+ }
188859
+ // `sibling` is now the first non-text node after the run, or null.
188860
+ var removed = child.nextSibling;
188861
+ while (removed !== sibling) {
188862
+ var following = removed.nextSibling;
188863
+ removed.parentNode = null;
188864
+ removed.previousSibling = null;
188865
+ removed.nextSibling = null;
188866
+ removed = following;
188867
+ }
188868
+ child.nextSibling = sibling;
188869
+ if (sibling !== null) {
188870
+ sibling.previousSibling = child;
188871
+ } else {
188872
+ node.lastChild = child;
188873
+ }
188874
+ child.appendData(tail.join('')); // single O(K) string rebuild
188875
+ _onUpdateChild(node.ownerDocument, node); // single O(K) re-index
188876
+ child = sibling;
188681
188877
  } else {
188682
188878
  child = next;
188683
188879
  }
@@ -189488,8 +189684,10 @@ function requireDom () {
189488
189684
  * - it does not do any input validation on the arguments and doesn't throw "InvalidCharacterError".
189489
189685
  *
189490
189686
  * Note: When the resulting document is serialized with `requireWellFormed: true`, the
189491
- * serializer throws with code `INVALID_STATE_ERR` if `.data` contains `?>` (W3C DOM Parsing
189492
- * §3.2.1.7). Without that option the data is emitted verbatim.
189687
+ * serializer throws with code `INVALID_STATE_ERR` if `.target` is not a valid XML `NCName`
189688
+ * (a `Name` with no colon) or is an ASCII case-insensitive match for `"xml"`, or if `.data`
189689
+ * contains `?>` (W3C DOM Parsing §3.2.1.7). Without that option the target and data are
189690
+ * emitted verbatim.
189493
189691
  *
189494
189692
  * @param {string} target
189495
189693
  * @param {string} data
@@ -189514,7 +189712,27 @@ function requireDom () {
189514
189712
  node.specified = true;
189515
189713
  return node;
189516
189714
  },
189715
+ /**
189716
+ * Creates an EntityReference object, serialized as `&name;`.
189717
+ *
189718
+ * The `name` is validated against the XML `Name` production at creation time; an invalid name
189719
+ * throws a `DOMException` with code `INVALID_CHARACTER_ERR`. When the resulting node is
189720
+ * serialized with `requireWellFormed: true`, the serializer re-validates `nodeName` and throws
189721
+ * a `DOMException` with code `INVALID_STATE_ERR` if a later `nodeName` mutation made it invalid;
189722
+ * without that option the name is emitted verbatim.
189723
+ *
189724
+ * Note: xmldom does not expand entities — the parser resolves entity references inline and never
189725
+ * constructs `EntityReference` nodes, so this method is the only producer.
189726
+ *
189727
+ * @param {string} name The name of the entity to reference.
189728
+ * @returns {EntityReference}
189729
+ * @throws {DOMException} With code `INVALID_CHARACTER_ERR` when `name` is not a valid XML `Name`.
189730
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-392B75AE
189731
+ */
189517
189732
  createEntityReference : function(name){
189733
+ if (!tagNamePattern.test(name)) {
189734
+ throw new DOMException(INVALID_CHARACTER_ERR, 'not a valid xml name "' + name + '"');
189735
+ }
189518
189736
  var node = new EntityReference();
189519
189737
  node.ownerDocument = this;
189520
189738
  node.nodeName = name;
@@ -189726,15 +189944,16 @@ function requireDom () {
189726
189944
  /**
189727
189945
  * Represents a DocumentType node (the `<!DOCTYPE ...>` declaration).
189728
189946
  *
189729
- * `publicId`, `systemId`, and `internalSubset` are plain own-property assignments.
189947
+ * `name`, `publicId`, `systemId`, and `internalSubset` are plain own-property assignments.
189730
189948
  * xmldom does not enforce the `readonly` constraint declared by the WHATWG DOM spec —
189731
189949
  * direct property writes succeed silently. Values are serialized verbatim when
189732
189950
  * `requireWellFormed` is false (the default). When the serializer is invoked with
189733
189951
  * `requireWellFormed: true` (via the 4th-parameter options object), it validates each
189734
- * field and throws `DOMException` with code `INVALID_STATE_ERR` on invalid values.
189952
+ * field — including `name`, which is checked against the XML `Name` production — and throws
189953
+ * `DOMException` with code `INVALID_STATE_ERR` on invalid values.
189735
189954
  *
189736
189955
  * @class
189737
- * @see https://developer.mozilla.org/en-US/docs/Web/API/DocumentType MDN
189956
+ * @see https://developer.mozilla.org/docs/Web/API/DocumentType MDN
189738
189957
  */
189739
189958
  function DocumentType() {
189740
189959
  } DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
@@ -189748,6 +189967,20 @@ function requireDom () {
189748
189967
  } Entity.prototype.nodeType = ENTITY_NODE;
189749
189968
  _extends(Entity,Node);
189750
189969
 
189970
+ /**
189971
+ * Represents an EntityReference node, serialized as `&nodeName;`.
189972
+ *
189973
+ * `nodeName` is the referenced entity's name, stored verbatim. When serialized with
189974
+ * `requireWellFormed: true`, the serializer validates `nodeName` against the XML `Name` production
189975
+ * and throws a `DOMException` with code `INVALID_STATE_ERR` if it does not match; without that
189976
+ * option the name is emitted verbatim between `&` and `;`.
189977
+ *
189978
+ * Note: xmldom does not expand entities — the parser resolves entity references inline and never
189979
+ * constructs `EntityReference` nodes, so the only producer is `Document.createEntityReference`.
189980
+ *
189981
+ * @class
189982
+ * @see https://www.w3.org/TR/xml/#NT-Name
189983
+ */
189751
189984
  function EntityReference() {
189752
189985
  } EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
189753
189986
  _extends(EntityReference,Node);
@@ -189790,12 +190023,15 @@ function requireDom () {
189790
190023
  * not a valid XML QName,
189791
190024
  * - a CDATASection node's data contains `"]]>"`,
189792
190025
  * - a Comment node's data contains `"-->"` (bare `"--"` does not throw on this branch),
189793
- * - a ProcessingInstruction's data contains `"?>"`,
190026
+ * - a ProcessingInstruction's target is not a valid XML `NCName` (a `Name` with no colon) or is
190027
+ * an ASCII case-insensitive match for `"xml"`, or its data contains `"?>"`,
190028
+ * - a DocumentType's `name` is not a valid XML `Name` (XML 1.0 production [5]),
189794
190029
  * - a DocumentType's `publicId` is non-empty and does not match the XML `PubidLiteral`
189795
190030
  * production,
189796
190031
  * - a DocumentType's `systemId` is non-empty and does not match the XML `SystemLiteral`
189797
- * production, or
189798
- * - a DocumentType's `internalSubset` contains `"]>"`.
190032
+ * production,
190033
+ * - a DocumentType's `internalSubset` contains `"]>"`, or
190034
+ * - an EntityReference's `nodeName` is not a valid XML `Name` (XML 1.0 production [5]).
189799
190035
  * Note: xmldom does not enforce `readonly` on DocumentType fields — direct property
189800
190036
  * writes succeed and are covered by the serializer-level checks above.
189801
190037
  * @see https://html.spec.whatwg.org/#dom-xmlserializer-serializetostring
@@ -190050,6 +190286,9 @@ function requireDom () {
190050
190286
 
190051
190287
  case DOCUMENT_TYPE_NODE:
190052
190288
  if (requireWellFormed) {
190289
+ if (!tagNamePattern.test(n.name)) {
190290
+ throw new DOMException(INVALID_STATE_ERR, 'The doctype name "' + n.name + '" is not a valid XML Name');
190291
+ }
190053
190292
  if (n.publicId && !/^("[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%']*"|'[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%'"]*')$/.test(n.publicId)) {
190054
190293
  throw new DOMException(INVALID_STATE_ERR, 'DocumentType publicId is not a valid PubidLiteral');
190055
190294
  }
@@ -190081,13 +190320,27 @@ function requireDom () {
190081
190320
  return null;
190082
190321
 
190083
190322
  case PROCESSING_INSTRUCTION_NODE:
190084
- if (requireWellFormed && n.data.indexOf('?>') !== -1) {
190085
- throw new DOMException(INVALID_STATE_ERR, 'The ProcessingInstruction data contains "?>"');
190323
+ if (requireWellFormed) {
190324
+ if (!tagNamePattern.test(n.target) || n.target.indexOf(':') !== -1 || n.target.toLowerCase() === 'xml') {
190325
+ throw new DOMException(
190326
+ INVALID_STATE_ERR,
190327
+ 'The processing instruction target "' + n.target + '" is not a valid XML NCName or is reserved'
190328
+ );
190329
+ }
190330
+ if (n.data.indexOf('?>') !== -1) {
190331
+ throw new DOMException(INVALID_STATE_ERR, 'The ProcessingInstruction data contains "?>"');
190332
+ }
190086
190333
  }
190087
190334
  buf.push('<?', n.target, ' ', n.data, '?>');
190088
190335
  return null;
190089
190336
 
190090
190337
  case ENTITY_REFERENCE_NODE:
190338
+ if (requireWellFormed && !tagNamePattern.test(n.nodeName)) {
190339
+ throw new DOMException(
190340
+ INVALID_STATE_ERR,
190341
+ 'The entity reference name "' + n.nodeName + '" is not a valid XML Name'
190342
+ );
190343
+ }
190091
190344
  buf.push('&', n.nodeName, ';');
190092
190345
  return null;
190093
190346
 
@@ -192580,7 +192833,13 @@ function requireSax () {
192580
192833
  switch(source.charAt(tagStart+1)){
192581
192834
  case '/':
192582
192835
  var end = source.indexOf('>',tagStart+3);
192583
- var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, '');
192836
+ // Anchored trailing-whitespace trim. The former `/[ \t\n\r]+$/g` backtracked
192837
+ // quadratically on a name shaped `whitespace-run + non-whitespace char`
192838
+ // (an end tag `</ … x>`): from every start position it extended `[ws]+`
192839
+ // to the end and then failed the `$` anchor. This anchored form matches the
192840
+ // whole string once and captures everything up to the last non-whitespace
192841
+ // character, so it trims in linear time with byte-identical output.
192842
+ var tagName = source.substring(tagStart + 2, end).replace(/^([\s\S]*?[^ \t\n\r])?[ \t\n\r]*$/, '$1');
192584
192843
  var config = parseStack.pop();
192585
192844
  if(end<0){
192586
192845
 
@@ -192591,6 +192850,14 @@ function requireSax () {
192591
192850
  tagName = tagName.replace(/[\s<].*/,'');
192592
192851
  errorHandler.error("end tag name: "+tagName+' maybe not complete');
192593
192852
  end = tagStart+1+tagName.length;
192853
+ }else if(/[ \t\n\r]/.test(tagName) && tagNamePattern.test(tagName.split(/[ \t\n\r]/)[0])){
192854
+ // The XML `ETag` production is `'</' Name S? '>'`: only optional whitespace may follow
192855
+ // the `Name`. A valid `Name` followed by whitespace and non-whitespace residue (e.g.
192856
+ // `</a\nbogus>` or `</a bogus>`) is not well-formed, but historically it was silently
192857
+ // accepted (the malformed end tag ignored, the residue dropped, the element left on the
192858
+ // stack). Report it as a recoverable `error` (which a custom errorHandler may escalate to
192859
+ // fatal) while keeping the existing recovery so the parsed DOM stays byte-identical.
192860
+ errorHandler.error('end tag name is followed by whitespace and trailing content: "'+tagName+'"');
192594
192861
  }
192595
192862
  var localNSMap = config.localNSMap;
192596
192863
  var endMatch = config.tagName == tagName;
@@ -192714,6 +192981,15 @@ function requireSax () {
192714
192981
  var s = S_TAG;//status
192715
192982
  while(true){
192716
192983
  var c = source.charAt(p);
192984
+ if (s === S_TAG && c === '<') {
192985
+ // A `<` can never occur inside a tag name. Without this guard the scan runs
192986
+ // on to the next `>` (or EOF) before the tag name is rejected, so a document
192987
+ // with many `<` inside a malformed tag makes each one-character recovery step
192988
+ // re-scan to the distant `>` — O(n^2). Stopping at the `<` keeps each recovery
192989
+ // step bounded. The candidate scanned so far is reported raw, consistent with
192990
+ // the sibling invalid-tag-name throw below.
192991
+ throw new Error('unexpected < in tag name: ' + source.slice(start, p));
192992
+ }
192717
192993
  switch(c){
192718
192994
  case '=':
192719
192995
  if(s === S_ATTR){//attrName
@@ -192906,9 +193182,13 @@ function requireSax () {
192906
193182
  if(nsPrefix !== false){//hack!!
192907
193183
  if(localNSMap == null){
192908
193184
  localNSMap = {};
192909
- //console.log(currentNSMap,0)
192910
- _copy(currentNSMap,currentNSMap={});
192911
- //console.log(currentNSMap,1)
193185
+ // Derive the child scope's namespace map by prototype-chain inheritance
193186
+ // instead of a flat copy: lookups inherit ancestor prefixes transparently,
193187
+ // so a document nesting N scopes retains O(N) map entries rather than
193188
+ // sum(1..N) = O(N^2). localNSMap stays a flat own-only record of the
193189
+ // prefixes declared at THIS element, so own-property enumeration
193190
+ // (endPrefixMapping below) still reports only local declarations.
193191
+ currentNSMap = Object.create(currentNSMap);
192912
193192
  }
192913
193193
  currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
192914
193194
  a.uri = NAMESPACE.XMLNS;