@wavemaker/angular-app 11.15.1-rc.248 → 11.15.2-rc.249
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dependencies/pipe-provider.cjs.js +1154 -624
- package/dependencies/transpilation-web.cjs.js +577 -312
- package/dependency-report.html +1 -1
- package/npm-shrinkwrap.json +203 -206
- package/package-lock.json +203 -206
- package/package.json +5 -5
|
@@ -131288,14 +131288,14 @@ function requireDom$1 () {
|
|
|
131288
131288
|
ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2);
|
|
131289
131289
|
var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3);
|
|
131290
131290
|
ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4);
|
|
131291
|
-
ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
|
|
131291
|
+
var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
|
|
131292
131292
|
ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6);
|
|
131293
131293
|
ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7);
|
|
131294
131294
|
var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8);
|
|
131295
131295
|
ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9);
|
|
131296
131296
|
var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10);
|
|
131297
131297
|
//level2
|
|
131298
|
-
ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
|
|
131298
|
+
var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
|
|
131299
131299
|
ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12);
|
|
131300
131300
|
ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13);
|
|
131301
131301
|
ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14);
|
|
@@ -131345,9 +131345,10 @@ function requireDom$1 () {
|
|
|
131345
131345
|
item: function(index) {
|
|
131346
131346
|
return index >= 0 && index < this.length ? this[index] : null;
|
|
131347
131347
|
},
|
|
131348
|
-
toString:function(isHTML,nodeFilter){
|
|
131348
|
+
toString:function(isHTML,nodeFilter,options){
|
|
131349
|
+
var requireWellFormed = !!options && !!options.requireWellFormed;
|
|
131349
131350
|
for(var buf = [], i = 0;i<this.length;i++){
|
|
131350
|
-
serializeToString(this[i],buf,isHTML,nodeFilter);
|
|
131351
|
+
serializeToString(this[i],buf,isHTML,nodeFilter,null,requireWellFormed);
|
|
131351
131352
|
}
|
|
131352
131353
|
return buf.join('');
|
|
131353
131354
|
},
|
|
@@ -131592,13 +131593,28 @@ function requireDom$1 () {
|
|
|
131592
131593
|
/**
|
|
131593
131594
|
* Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.
|
|
131594
131595
|
*
|
|
131595
|
-
* __This
|
|
131596
|
+
* __This implementation differs from the specification:__
|
|
131596
131597
|
* - this implementation is not validating names or qualified names
|
|
131597
131598
|
* (when parsing XML strings, the SAX parser takes care of that)
|
|
131598
131599
|
*
|
|
131600
|
+
* Note: `internalSubset` can only be introduced via a direct property write to `node.internalSubset` after creation.
|
|
131601
|
+
* Creation-time validation of `publicId`, `systemId` is not enforced.
|
|
131602
|
+
* The serializer-level check covers all mutation vectors, including direct property writes.
|
|
131603
|
+
* `internalSubset` is only serialized as `[ ... ]` when both `publicId` and `systemId` are
|
|
131604
|
+
* absent (empty or `'.'`) — if either external identifier is present, `internalSubset` is
|
|
131605
|
+
* silently omitted from the serialized output.
|
|
131606
|
+
*
|
|
131599
131607
|
* @param {string} qualifiedName
|
|
131600
131608
|
* @param {string} [publicId]
|
|
131609
|
+
* The external subset public identifier. Stored verbatim including surrounding quotes.
|
|
131610
|
+
* When serialized with `requireWellFormed: true` (via the 4th-parameter options object),
|
|
131611
|
+
* throws `DOMException` with code `INVALID_STATE_ERR` if the value is non-empty and does
|
|
131612
|
+
* not match the XML `PubidLiteral` production (W3C DOM Parsing §3.2.1.3; XML 1.0 [12]).
|
|
131601
131613
|
* @param {string} [systemId]
|
|
131614
|
+
* The external subset system identifier. Stored verbatim including surrounding quotes.
|
|
131615
|
+
* When serialized with `requireWellFormed: true`, throws `DOMException` with code
|
|
131616
|
+
* `INVALID_STATE_ERR` if the value is non-empty and does not match the XML `SystemLiteral`
|
|
131617
|
+
* production (W3C DOM Parsing §3.2.1.3; XML 1.0 [11]).
|
|
131602
131618
|
* @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation
|
|
131603
131619
|
* or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`
|
|
131604
131620
|
*
|
|
@@ -131664,18 +131680,44 @@ function requireDom$1 () {
|
|
|
131664
131680
|
return cloneNode(this.ownerDocument||this,this,deep);
|
|
131665
131681
|
},
|
|
131666
131682
|
// Modified in DOM Level 2:
|
|
131667
|
-
|
|
131668
|
-
|
|
131669
|
-
|
|
131670
|
-
|
|
131671
|
-
|
|
131672
|
-
|
|
131673
|
-
|
|
131674
|
-
|
|
131675
|
-
|
|
131676
|
-
|
|
131677
|
-
|
|
131678
|
-
|
|
131683
|
+
/**
|
|
131684
|
+
* Puts the specified node and all of its subtree into a "normalized" form. In a normalized
|
|
131685
|
+
* subtree, no text nodes in the subtree are empty and there are no adjacent text nodes.
|
|
131686
|
+
*
|
|
131687
|
+
* Specifically, this method merges any adjacent text nodes (i.e., nodes for which `nodeType`
|
|
131688
|
+
* is `TEXT_NODE`) into a single node with the combined data. It also removes any empty text
|
|
131689
|
+
* nodes.
|
|
131690
|
+
*
|
|
131691
|
+
* This method iteratively traverses all child nodes to normalize all descendant nodes within
|
|
131692
|
+
* the subtree.
|
|
131693
|
+
*
|
|
131694
|
+
* @throws {DOMException}
|
|
131695
|
+
* May throw a DOMException if operations within removeChild or appendData (which are
|
|
131696
|
+
* potentially invoked in this method) do not meet their specific constraints.
|
|
131697
|
+
* @see {@link Node.removeChild}
|
|
131698
|
+
* @see {@link CharacterData.appendData}
|
|
131699
|
+
* @see ../docs/walk-dom.md.
|
|
131700
|
+
*/
|
|
131701
|
+
normalize: function () {
|
|
131702
|
+
walkDOM(this, null, {
|
|
131703
|
+
enter: function (node) {
|
|
131704
|
+
// Merge adjacent text children of node before walkDOM schedules them.
|
|
131705
|
+
// walkDOM reads lastChild/previousSibling after enter returns, so the
|
|
131706
|
+
// surviving post-merge children are what it descends into.
|
|
131707
|
+
var child = node.firstChild;
|
|
131708
|
+
while (child) {
|
|
131709
|
+
var next = child.nextSibling;
|
|
131710
|
+
if (next !== null && next.nodeType === TEXT_NODE && child.nodeType === TEXT_NODE) {
|
|
131711
|
+
node.removeChild(next);
|
|
131712
|
+
child.appendData(next.data);
|
|
131713
|
+
// Do not advance child: re-check new nextSibling for another text run
|
|
131714
|
+
} else {
|
|
131715
|
+
child = next;
|
|
131716
|
+
}
|
|
131717
|
+
}
|
|
131718
|
+
return true; // descend into surviving children
|
|
131719
|
+
},
|
|
131720
|
+
});
|
|
131679
131721
|
},
|
|
131680
131722
|
// Introduced in DOM Level 2:
|
|
131681
131723
|
isSupported:function(feature, version){
|
|
@@ -131751,21 +131793,103 @@ function requireDom$1 () {
|
|
|
131751
131793
|
copy(NodeType,Node.prototype);
|
|
131752
131794
|
|
|
131753
131795
|
/**
|
|
131754
|
-
* @param
|
|
131755
|
-
*
|
|
131796
|
+
* @param {Node} node
|
|
131797
|
+
* Root of the subtree to visit.
|
|
131798
|
+
* @param {function(Node): boolean} callback
|
|
131799
|
+
* Called for each node in depth-first pre-order. Return a truthy value to stop traversal early.
|
|
131800
|
+
* @return {boolean} `true` if traversal was aborted by the callback, `false` otherwise.
|
|
131756
131801
|
*/
|
|
131757
|
-
function _visitNode(node,callback){
|
|
131758
|
-
|
|
131759
|
-
return true;
|
|
131760
|
-
}
|
|
131761
|
-
if(node = node.firstChild){
|
|
131762
|
-
do{
|
|
131763
|
-
if(_visitNode(node,callback)){return true}
|
|
131764
|
-
}while(node=node.nextSibling)
|
|
131765
|
-
}
|
|
131802
|
+
function _visitNode(node, callback) {
|
|
131803
|
+
return walkDOM(node, null, { enter: function (n) { return callback(n) ? walkDOM.STOP : true; } }) === walkDOM.STOP;
|
|
131766
131804
|
}
|
|
131767
131805
|
|
|
131806
|
+
/**
|
|
131807
|
+
* Depth-first pre/post-order DOM tree walker.
|
|
131808
|
+
*
|
|
131809
|
+
* Visits every node in the subtree rooted at `node`. For each node:
|
|
131810
|
+
*
|
|
131811
|
+
* 1. Calls `callbacks.enter(node, context)` before descending into the node's children. The
|
|
131812
|
+
* return value becomes the `context` passed to each child's `enter` call and to the matching
|
|
131813
|
+
* `exit` call.
|
|
131814
|
+
* 2. If `enter` returns `null` or `undefined`, the node's children are skipped;
|
|
131815
|
+
* sibling traversal continues normally.
|
|
131816
|
+
* 3. If `enter` returns `walkDOM.STOP`, the entire traversal is aborted immediately — no
|
|
131817
|
+
* further `enter` or `exit` calls are made.
|
|
131818
|
+
* 4. `lastChild` and `previousSibling` are read **after** `enter` returns, so `enter` may
|
|
131819
|
+
* safely modify the node's own child list before the walker descends. Modifying siblings of
|
|
131820
|
+
* the current node or any other part of the tree produces unpredictable results: nodes already
|
|
131821
|
+
* queued on the stack are visited regardless of DOM changes, and newly inserted nodes outside
|
|
131822
|
+
* the current child list are never visited.
|
|
131823
|
+
* 5. Calls `callbacks.exit(node, context)` (if provided) after all of a node's children have
|
|
131824
|
+
* been visited, passing the same `context` that `enter`
|
|
131825
|
+
* returned for that node.
|
|
131826
|
+
*
|
|
131827
|
+
* This implementation uses an explicit stack and does not recurse — it is safe on arbitrarily
|
|
131828
|
+
* deep trees.
|
|
131829
|
+
*
|
|
131830
|
+
* @param {Node} node
|
|
131831
|
+
* Root of the subtree to walk.
|
|
131832
|
+
* @param {*} context
|
|
131833
|
+
* Initial context value passed to the root node's `enter`.
|
|
131834
|
+
* @param {{ enter: function(Node, *): *, exit?: function(Node, *): void }} callbacks
|
|
131835
|
+
* @returns {void | walkDOM.STOP}
|
|
131836
|
+
* @see ../docs/walk-dom.md.
|
|
131837
|
+
*/
|
|
131838
|
+
function walkDOM(node, context, callbacks) {
|
|
131839
|
+
// Each stack frame is {node, context, phase}:
|
|
131840
|
+
// walkDOM.ENTER — call enter, then push children
|
|
131841
|
+
// walkDOM.EXIT — call exit
|
|
131842
|
+
var stack = [{ node: node, context: context, phase: walkDOM.ENTER }];
|
|
131843
|
+
while (stack.length > 0) {
|
|
131844
|
+
var frame = stack.pop();
|
|
131845
|
+
if (frame.phase === walkDOM.ENTER) {
|
|
131846
|
+
var childContext = callbacks.enter(frame.node, frame.context);
|
|
131847
|
+
if (childContext === walkDOM.STOP) {
|
|
131848
|
+
return walkDOM.STOP;
|
|
131849
|
+
}
|
|
131850
|
+
// Push exit frame before children so it fires after all children are processed (Last In First Out)
|
|
131851
|
+
stack.push({ node: frame.node, context: childContext, phase: walkDOM.EXIT });
|
|
131852
|
+
if (childContext === null || childContext === undefined) {
|
|
131853
|
+
continue; // skip children
|
|
131854
|
+
}
|
|
131855
|
+
// lastChild is read after enter returns, so enter may modify the child list.
|
|
131856
|
+
var child = frame.node.lastChild;
|
|
131857
|
+
// Traverse from lastChild backwards so that pushing onto the stack
|
|
131858
|
+
// naturally yields firstChild on top (processed first).
|
|
131859
|
+
while (child) {
|
|
131860
|
+
stack.push({ node: child, context: childContext, phase: walkDOM.ENTER });
|
|
131861
|
+
child = child.previousSibling;
|
|
131862
|
+
}
|
|
131863
|
+
} else {
|
|
131864
|
+
// frame.phase === walkDOM.EXIT
|
|
131865
|
+
if (callbacks.exit) {
|
|
131866
|
+
callbacks.exit(frame.node, frame.context);
|
|
131867
|
+
}
|
|
131868
|
+
}
|
|
131869
|
+
}
|
|
131870
|
+
}
|
|
131768
131871
|
|
|
131872
|
+
/**
|
|
131873
|
+
* Sentinel value returned from a `walkDOM` `enter` callback to abort the entire traversal
|
|
131874
|
+
* immediately.
|
|
131875
|
+
*
|
|
131876
|
+
* @type {symbol}
|
|
131877
|
+
*/
|
|
131878
|
+
walkDOM.STOP = Symbol('walkDOM.STOP');
|
|
131879
|
+
/**
|
|
131880
|
+
* Phase constant for a stack frame that has not yet been visited.
|
|
131881
|
+
* The `enter` callback is called and children are scheduled.
|
|
131882
|
+
*
|
|
131883
|
+
* @type {number}
|
|
131884
|
+
*/
|
|
131885
|
+
walkDOM.ENTER = 0;
|
|
131886
|
+
/**
|
|
131887
|
+
* Phase constant for a stack frame whose subtree has been fully visited.
|
|
131888
|
+
* The `exit` callback is called.
|
|
131889
|
+
*
|
|
131890
|
+
* @type {number}
|
|
131891
|
+
*/
|
|
131892
|
+
walkDOM.EXIT = 1;
|
|
131769
131893
|
|
|
131770
131894
|
function Document(){
|
|
131771
131895
|
this.ownerDocument = this;
|
|
@@ -132369,12 +132493,44 @@ function requireDom$1 () {
|
|
|
132369
132493
|
node.appendData(data);
|
|
132370
132494
|
return node;
|
|
132371
132495
|
},
|
|
132496
|
+
/**
|
|
132497
|
+
* Returns a new CDATASection node whose data is `data`.
|
|
132498
|
+
*
|
|
132499
|
+
* __This implementation differs from the specification:__
|
|
132500
|
+
* - calling this method on an HTML document does not throw `NotSupportedError`.
|
|
132501
|
+
*
|
|
132502
|
+
* @param {string} data
|
|
132503
|
+
* @returns {CDATASection}
|
|
132504
|
+
* @throws DOMException with code `INVALID_CHARACTER_ERR` if `data` contains `"]]>"`.
|
|
132505
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createCDATASection
|
|
132506
|
+
* @see https://dom.spec.whatwg.org/#dom-document-createcdatasection
|
|
132507
|
+
*/
|
|
132372
132508
|
createCDATASection : function(data){
|
|
132509
|
+
if (data.indexOf(']]>') !== -1) {
|
|
132510
|
+
throw new DOMException(INVALID_CHARACTER_ERR, 'data contains "]]>"');
|
|
132511
|
+
}
|
|
132373
132512
|
var node = new CDATASection();
|
|
132374
132513
|
node.ownerDocument = this;
|
|
132375
132514
|
node.appendData(data);
|
|
132376
132515
|
return node;
|
|
132377
132516
|
},
|
|
132517
|
+
/**
|
|
132518
|
+
* Returns a ProcessingInstruction node whose target is target and data is data.
|
|
132519
|
+
*
|
|
132520
|
+
* __This implementation differs from the specification:__
|
|
132521
|
+
* - it does not do any input validation on the arguments and doesn't throw "InvalidCharacterError".
|
|
132522
|
+
*
|
|
132523
|
+
* Note: When the resulting document is serialized with `requireWellFormed: true`, the
|
|
132524
|
+
* serializer throws with code `INVALID_STATE_ERR` if `.data` contains `?>` (W3C DOM Parsing
|
|
132525
|
+
* §3.2.1.7). Without that option the data is emitted verbatim.
|
|
132526
|
+
*
|
|
132527
|
+
* @param {string} target
|
|
132528
|
+
* @param {string} data
|
|
132529
|
+
* @returns {ProcessingInstruction}
|
|
132530
|
+
* @see https://developer.mozilla.org/docs/Web/API/Document/createProcessingInstruction
|
|
132531
|
+
* @see https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
|
|
132532
|
+
* @see https://www.w3.org/TR/DOM-Parsing/#dfn-concept-serialize-xml §3.2.1.7
|
|
132533
|
+
*/
|
|
132378
132534
|
createProcessingInstruction : function(target,data){
|
|
132379
132535
|
var node = new ProcessingInstruction();
|
|
132380
132536
|
node.ownerDocument = this;
|
|
@@ -132600,6 +132756,19 @@ function requireDom$1 () {
|
|
|
132600
132756
|
_extends(CDATASection,CharacterData);
|
|
132601
132757
|
|
|
132602
132758
|
|
|
132759
|
+
/**
|
|
132760
|
+
* Represents a DocumentType node (the `<!DOCTYPE ...>` declaration).
|
|
132761
|
+
*
|
|
132762
|
+
* `publicId`, `systemId`, and `internalSubset` are plain own-property assignments.
|
|
132763
|
+
* xmldom does not enforce the `readonly` constraint declared by the WHATWG DOM spec —
|
|
132764
|
+
* direct property writes succeed silently. Values are serialized verbatim when
|
|
132765
|
+
* `requireWellFormed` is false (the default). When the serializer is invoked with
|
|
132766
|
+
* `requireWellFormed: true` (via the 4th-parameter options object), it validates each
|
|
132767
|
+
* field and throws `DOMException` with code `INVALID_STATE_ERR` on invalid values.
|
|
132768
|
+
*
|
|
132769
|
+
* @class
|
|
132770
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DocumentType MDN
|
|
132771
|
+
*/
|
|
132603
132772
|
function DocumentType() {
|
|
132604
132773
|
} DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
|
|
132605
132774
|
_extends(DocumentType,Node);
|
|
@@ -132627,11 +132796,48 @@ function requireDom$1 () {
|
|
|
132627
132796
|
ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
|
|
132628
132797
|
_extends(ProcessingInstruction,Node);
|
|
132629
132798
|
function XMLSerializer(){}
|
|
132630
|
-
|
|
132631
|
-
|
|
132799
|
+
/**
|
|
132800
|
+
* Returns the result of serializing `node` to XML.
|
|
132801
|
+
*
|
|
132802
|
+
* When `options.requireWellFormed` is `true`, the serializer throws for content that would
|
|
132803
|
+
* produce ill-formed XML.
|
|
132804
|
+
*
|
|
132805
|
+
* __This implementation differs from the specification:__
|
|
132806
|
+
* - CDATASection nodes whose data contains `]]>` are serialized by splitting the section
|
|
132807
|
+
* at each `]]>` occurrence (following W3C DOM Level 3 Core `split-cdata-sections`
|
|
132808
|
+
* default behaviour) unless `requireWellFormed` is `true`.
|
|
132809
|
+
* - when `requireWellFormed` is `true`, `DOMException` with code `INVALID_STATE_ERR`
|
|
132810
|
+
* is only thrown to prevent injection vectors, not for all the spec mandated checks.
|
|
132811
|
+
*
|
|
132812
|
+
* @param {Node} node
|
|
132813
|
+
* @param {boolean} [isHtml]
|
|
132814
|
+
* @param {function} [nodeFilter]
|
|
132815
|
+
* @param {Object} [options]
|
|
132816
|
+
* @param {boolean} [options.requireWellFormed=false]
|
|
132817
|
+
* When `true`, throws for content that would produce ill-formed XML.
|
|
132818
|
+
* @returns {string}
|
|
132819
|
+
* @throws {DOMException}
|
|
132820
|
+
* With code `INVALID_STATE_ERR` when `requireWellFormed` is `true` and:
|
|
132821
|
+
* - a CDATASection node's data contains `"]]>"`,
|
|
132822
|
+
* - a Comment node's data contains `"-->"` (bare `"--"` does not throw on this branch),
|
|
132823
|
+
* - a ProcessingInstruction's data contains `"?>"`,
|
|
132824
|
+
* - a DocumentType's `publicId` is non-empty and does not match the XML `PubidLiteral`
|
|
132825
|
+
* production,
|
|
132826
|
+
* - a DocumentType's `systemId` is non-empty and does not match the XML `SystemLiteral`
|
|
132827
|
+
* production, or
|
|
132828
|
+
* - a DocumentType's `internalSubset` contains `"]>"`.
|
|
132829
|
+
* Note: xmldom does not enforce `readonly` on DocumentType fields — direct property
|
|
132830
|
+
* writes succeed and are covered by the serializer-level checks above.
|
|
132831
|
+
* @see https://html.spec.whatwg.org/#dom-xmlserializer-serializetostring
|
|
132832
|
+
* @see https://w3c.github.io/DOM-Parsing/#xml-serialization
|
|
132833
|
+
* @see https://github.com/w3c/DOM-Parsing/issues/84
|
|
132834
|
+
*/
|
|
132835
|
+
XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter,options){
|
|
132836
|
+
return nodeSerializeToString.call(node,isHtml,nodeFilter,options);
|
|
132632
132837
|
};
|
|
132633
132838
|
Node.prototype.toString = nodeSerializeToString;
|
|
132634
|
-
function nodeSerializeToString(isHtml,nodeFilter){
|
|
132839
|
+
function nodeSerializeToString(isHtml,nodeFilter,options){
|
|
132840
|
+
var requireWellFormed = !!options && !!options.requireWellFormed;
|
|
132635
132841
|
var buf = [];
|
|
132636
132842
|
var refNode = this.nodeType == 9 && this.documentElement || this;
|
|
132637
132843
|
var prefix = refNode.prefix;
|
|
@@ -132648,7 +132854,7 @@ function requireDom$1 () {
|
|
|
132648
132854
|
];
|
|
132649
132855
|
}
|
|
132650
132856
|
}
|
|
132651
|
-
serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces);
|
|
132857
|
+
serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces,requireWellFormed);
|
|
132652
132858
|
//console.log('###',this.nodeType,uri,prefix,buf.join(''))
|
|
132653
132859
|
return buf.join('');
|
|
132654
132860
|
}
|
|
@@ -132697,271 +132903,323 @@ function requireDom$1 () {
|
|
|
132697
132903
|
buf.push(' ', qualifiedName, '="', value.replace(/[<>&"\t\n\r]/g, _xmlEncoder), '"');
|
|
132698
132904
|
}
|
|
132699
132905
|
|
|
132700
|
-
function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
|
|
132906
|
+
function serializeToString(node, buf, isHTML, nodeFilter, visibleNamespaces, requireWellFormed) {
|
|
132701
132907
|
if (!visibleNamespaces) {
|
|
132702
132908
|
visibleNamespaces = [];
|
|
132703
132909
|
}
|
|
132704
|
-
|
|
132705
|
-
|
|
132706
|
-
|
|
132707
|
-
|
|
132708
|
-
|
|
132709
|
-
|
|
132710
|
-
|
|
132711
|
-
|
|
132712
|
-
|
|
132713
|
-
|
|
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
|
|
132910
|
+
walkDOM(node, { ns: visibleNamespaces, isHTML: isHTML }, {
|
|
132911
|
+
enter: function (n, ctx) {
|
|
132912
|
+
var ns = ctx.ns;
|
|
132913
|
+
var html = ctx.isHTML;
|
|
132914
|
+
|
|
132915
|
+
if (nodeFilter) {
|
|
132916
|
+
n = nodeFilter(n);
|
|
132917
|
+
if (n) {
|
|
132918
|
+
if (typeof n == 'string') {
|
|
132919
|
+
buf.push(n);
|
|
132920
|
+
return null;
|
|
132744
132921
|
}
|
|
132922
|
+
} else {
|
|
132923
|
+
return null;
|
|
132745
132924
|
}
|
|
132746
132925
|
}
|
|
132747
|
-
|
|
132748
|
-
|
|
132749
|
-
|
|
132750
|
-
|
|
132751
|
-
|
|
132752
|
-
|
|
132926
|
+
|
|
132927
|
+
switch (n.nodeType) {
|
|
132928
|
+
case ELEMENT_NODE:
|
|
132929
|
+
var attrs = n.attributes;
|
|
132930
|
+
var len = attrs.length;
|
|
132931
|
+
var nodeName = n.tagName;
|
|
132932
|
+
|
|
132933
|
+
html = NAMESPACE.isHTML(n.namespaceURI) || html;
|
|
132934
|
+
|
|
132935
|
+
var prefixedNodeName = nodeName;
|
|
132936
|
+
if (!html && !n.prefix && n.namespaceURI) {
|
|
132937
|
+
var defaultNS;
|
|
132938
|
+
// lookup current default ns from `xmlns` attribute
|
|
132939
|
+
for (var ai = 0; ai < attrs.length; ai++) {
|
|
132940
|
+
if (attrs.item(ai).name === 'xmlns') {
|
|
132941
|
+
defaultNS = attrs.item(ai).value;
|
|
132942
|
+
break;
|
|
132943
|
+
}
|
|
132944
|
+
}
|
|
132945
|
+
if (!defaultNS) {
|
|
132946
|
+
// lookup current default ns in visibleNamespaces
|
|
132947
|
+
for (var nsi = ns.length - 1; nsi >= 0; nsi--) {
|
|
132948
|
+
var nsEntry = ns[nsi];
|
|
132949
|
+
if (nsEntry.prefix === '' && nsEntry.namespace === n.namespaceURI) {
|
|
132950
|
+
defaultNS = nsEntry.namespace;
|
|
132951
|
+
break;
|
|
132952
|
+
}
|
|
132953
|
+
}
|
|
132954
|
+
}
|
|
132955
|
+
if (defaultNS !== n.namespaceURI) {
|
|
132956
|
+
for (var nsi = ns.length - 1; nsi >= 0; nsi--) {
|
|
132957
|
+
var nsEntry = ns[nsi];
|
|
132958
|
+
if (nsEntry.namespace === n.namespaceURI) {
|
|
132959
|
+
if (nsEntry.prefix) {
|
|
132960
|
+
prefixedNodeName = nsEntry.prefix + ':' + nodeName;
|
|
132961
|
+
}
|
|
132962
|
+
break;
|
|
132963
|
+
}
|
|
132964
|
+
}
|
|
132753
132965
|
}
|
|
132754
|
-
break
|
|
132755
132966
|
}
|
|
132756
|
-
}
|
|
132757
|
-
}
|
|
132758
|
-
}
|
|
132759
132967
|
|
|
132760
|
-
|
|
132968
|
+
buf.push('<', prefixedNodeName);
|
|
132969
|
+
|
|
132970
|
+
// Build a fresh namespace snapshot for this element's children.
|
|
132971
|
+
// The slice prevents sibling elements from inheriting each other's declarations.
|
|
132972
|
+
var childNs = ns.slice();
|
|
132973
|
+
for (var i = 0; i < len; i++) {
|
|
132974
|
+
var attr = attrs.item(i);
|
|
132975
|
+
if (attr.prefix == 'xmlns') {
|
|
132976
|
+
childNs.push({ prefix: attr.localName, namespace: attr.value });
|
|
132977
|
+
} else if (attr.nodeName == 'xmlns') {
|
|
132978
|
+
childNs.push({ prefix: '', namespace: attr.value });
|
|
132979
|
+
}
|
|
132980
|
+
}
|
|
132761
132981
|
|
|
132762
|
-
|
|
132763
|
-
|
|
132764
|
-
|
|
132765
|
-
|
|
132766
|
-
|
|
132767
|
-
|
|
132768
|
-
|
|
132769
|
-
|
|
132770
|
-
|
|
132982
|
+
for (var i = 0; i < len; i++) {
|
|
132983
|
+
var attr = attrs.item(i);
|
|
132984
|
+
if (needNamespaceDefine(attr, html, childNs)) {
|
|
132985
|
+
var attrPrefix = attr.prefix || '';
|
|
132986
|
+
var uri = attr.namespaceURI;
|
|
132987
|
+
addSerializedAttribute(buf, attrPrefix ? 'xmlns:' + attrPrefix : 'xmlns', uri);
|
|
132988
|
+
childNs.push({ prefix: attrPrefix, namespace: uri });
|
|
132989
|
+
}
|
|
132990
|
+
// Apply nodeFilter and serialize the attribute.
|
|
132991
|
+
var filteredAttr = nodeFilter ? nodeFilter(attr) : attr;
|
|
132992
|
+
if (filteredAttr) {
|
|
132993
|
+
if (typeof filteredAttr === 'string') {
|
|
132994
|
+
buf.push(filteredAttr);
|
|
132995
|
+
} else {
|
|
132996
|
+
addSerializedAttribute(buf, filteredAttr.name, filteredAttr.value);
|
|
132997
|
+
}
|
|
132998
|
+
}
|
|
132999
|
+
}
|
|
132771
133000
|
|
|
132772
|
-
|
|
132773
|
-
|
|
132774
|
-
|
|
132775
|
-
|
|
132776
|
-
|
|
132777
|
-
|
|
132778
|
-
|
|
132779
|
-
}
|
|
132780
|
-
serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
|
|
132781
|
-
}
|
|
133001
|
+
// add namespace for current node
|
|
133002
|
+
if (nodeName === prefixedNodeName && needNamespaceDefine(n, html, childNs)) {
|
|
133003
|
+
var nodePrefix = n.prefix || '';
|
|
133004
|
+
var uri = n.namespaceURI;
|
|
133005
|
+
addSerializedAttribute(buf, nodePrefix ? 'xmlns:' + nodePrefix : 'xmlns', uri);
|
|
133006
|
+
childNs.push({ prefix: nodePrefix, namespace: uri });
|
|
133007
|
+
}
|
|
132782
133008
|
|
|
132783
|
-
|
|
132784
|
-
|
|
132785
|
-
|
|
132786
|
-
|
|
132787
|
-
|
|
132788
|
-
|
|
132789
|
-
|
|
133009
|
+
var child = n.firstChild;
|
|
133010
|
+
if (child || html && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)) {
|
|
133011
|
+
buf.push('>');
|
|
133012
|
+
if (html && /^script$/i.test(nodeName)) {
|
|
133013
|
+
// Inline serialization for <script> children; return null to skip walkDOM descent.
|
|
133014
|
+
while (child) {
|
|
133015
|
+
if (child.data) {
|
|
133016
|
+
buf.push(child.data);
|
|
133017
|
+
} else {
|
|
133018
|
+
serializeToString(child, buf, html, nodeFilter, childNs.slice(), requireWellFormed);
|
|
133019
|
+
}
|
|
133020
|
+
child = child.nextSibling;
|
|
133021
|
+
}
|
|
133022
|
+
buf.push('</', nodeName, '>');
|
|
133023
|
+
return null;
|
|
133024
|
+
}
|
|
133025
|
+
// Return child context; walkDOM descends and exit emits the closing tag.
|
|
133026
|
+
return { ns: childNs, isHTML: html, tag: prefixedNodeName };
|
|
133027
|
+
} else {
|
|
133028
|
+
buf.push('/>');
|
|
133029
|
+
return null;
|
|
133030
|
+
}
|
|
132790
133031
|
|
|
132791
|
-
|
|
132792
|
-
|
|
132793
|
-
|
|
132794
|
-
|
|
132795
|
-
|
|
132796
|
-
|
|
132797
|
-
|
|
132798
|
-
|
|
132799
|
-
|
|
133032
|
+
case DOCUMENT_NODE:
|
|
133033
|
+
case DOCUMENT_FRAGMENT_NODE:
|
|
133034
|
+
// Descend into children; exit is a no-op (tag is null).
|
|
133035
|
+
return { ns: ns.slice(), isHTML: html, tag: null };
|
|
133036
|
+
|
|
133037
|
+
case ATTRIBUTE_NODE:
|
|
133038
|
+
addSerializedAttribute(buf, n.name, n.value);
|
|
133039
|
+
return null;
|
|
133040
|
+
|
|
133041
|
+
case TEXT_NODE:
|
|
133042
|
+
/**
|
|
133043
|
+
* The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
|
|
133044
|
+
* except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section.
|
|
133045
|
+
* If they are needed elsewhere, they must be escaped using either numeric character references or the strings
|
|
133046
|
+
* `&` and `<` respectively.
|
|
133047
|
+
* The right angle bracket (>) may be represented using the string " > ", and must, for compatibility,
|
|
133048
|
+
* be escaped using either `>` or a character reference when it appears in the string `]]>` in content,
|
|
133049
|
+
* when that string is not marking the end of a CDATA section.
|
|
133050
|
+
*
|
|
133051
|
+
* In the content of elements, character data is any string of characters
|
|
133052
|
+
* which does not contain the start-delimiter of any markup
|
|
133053
|
+
* and does not include the CDATA-section-close delimiter, `]]>`.
|
|
133054
|
+
*
|
|
133055
|
+
* @see https://www.w3.org/TR/xml/#NT-CharData
|
|
133056
|
+
* @see https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node
|
|
133057
|
+
*/
|
|
133058
|
+
buf.push(n.data.replace(/[<&>]/g, _xmlEncoder));
|
|
133059
|
+
return null;
|
|
133060
|
+
|
|
133061
|
+
case CDATA_SECTION_NODE:
|
|
133062
|
+
if (requireWellFormed && n.data.indexOf(']]>') !== -1) {
|
|
133063
|
+
throw new DOMException(INVALID_STATE_ERR, 'The CDATASection data contains "]]>"');
|
|
132800
133064
|
}
|
|
132801
|
-
|
|
132802
|
-
|
|
132803
|
-
|
|
132804
|
-
|
|
132805
|
-
|
|
132806
|
-
|
|
132807
|
-
|
|
132808
|
-
|
|
132809
|
-
|
|
132810
|
-
|
|
132811
|
-
|
|
132812
|
-
|
|
132813
|
-
|
|
132814
|
-
|
|
132815
|
-
|
|
132816
|
-
|
|
132817
|
-
|
|
132818
|
-
|
|
132819
|
-
|
|
132820
|
-
|
|
132821
|
-
|
|
132822
|
-
|
|
132823
|
-
|
|
132824
|
-
|
|
132825
|
-
|
|
132826
|
-
|
|
132827
|
-
|
|
132828
|
-
|
|
132829
|
-
|
|
132830
|
-
|
|
132831
|
-
|
|
132832
|
-
|
|
132833
|
-
|
|
132834
|
-
|
|
132835
|
-
|
|
132836
|
-
|
|
132837
|
-
|
|
132838
|
-
|
|
132839
|
-
|
|
132840
|
-
|
|
132841
|
-
|
|
132842
|
-
|
|
132843
|
-
|
|
132844
|
-
|
|
132845
|
-
|
|
132846
|
-
|
|
132847
|
-
|
|
132848
|
-
|
|
132849
|
-
|
|
132850
|
-
|
|
132851
|
-
|
|
132852
|
-
|
|
132853
|
-
|
|
132854
|
-
|
|
132855
|
-
|
|
132856
|
-
|
|
132857
|
-
|
|
132858
|
-
|
|
133065
|
+
buf.push('<![CDATA[', n.data.replace(/]]>/g, ']]]]><![CDATA[>'), ']]>');
|
|
133066
|
+
return null;
|
|
133067
|
+
|
|
133068
|
+
case COMMENT_NODE:
|
|
133069
|
+
if (requireWellFormed && n.data.indexOf('-->') !== -1) {
|
|
133070
|
+
throw new DOMException(INVALID_STATE_ERR, 'The comment node data contains "-->"');
|
|
133071
|
+
}
|
|
133072
|
+
buf.push('<!--', n.data, '-->');
|
|
133073
|
+
return null;
|
|
133074
|
+
|
|
133075
|
+
case DOCUMENT_TYPE_NODE:
|
|
133076
|
+
if (requireWellFormed) {
|
|
133077
|
+
if (n.publicId && !/^("[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%']*"|'[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%'"]*')$/.test(n.publicId)) {
|
|
133078
|
+
throw new DOMException(INVALID_STATE_ERR, 'DocumentType publicId is not a valid PubidLiteral');
|
|
133079
|
+
}
|
|
133080
|
+
if (n.systemId && !/^("[^"]*"|'[^']*')$/.test(n.systemId)) {
|
|
133081
|
+
throw new DOMException(INVALID_STATE_ERR, 'DocumentType systemId is not a valid SystemLiteral');
|
|
133082
|
+
}
|
|
133083
|
+
if (n.internalSubset && n.internalSubset.indexOf(']>') !== -1) {
|
|
133084
|
+
throw new DOMException(INVALID_STATE_ERR, 'DocumentType internalSubset contains "]>"');
|
|
133085
|
+
}
|
|
133086
|
+
}
|
|
133087
|
+
var pubid = n.publicId;
|
|
133088
|
+
var sysid = n.systemId;
|
|
133089
|
+
buf.push('<!DOCTYPE ', n.name);
|
|
133090
|
+
if (pubid) {
|
|
133091
|
+
buf.push(' PUBLIC ', pubid);
|
|
133092
|
+
if (sysid && sysid != '.') {
|
|
133093
|
+
buf.push(' ', sysid);
|
|
133094
|
+
}
|
|
133095
|
+
buf.push('>');
|
|
133096
|
+
} else if (sysid && sysid != '.') {
|
|
133097
|
+
buf.push(' SYSTEM ', sysid, '>');
|
|
133098
|
+
} else {
|
|
133099
|
+
var sub = n.internalSubset;
|
|
133100
|
+
if (sub) {
|
|
133101
|
+
buf.push(' [', sub, ']');
|
|
133102
|
+
}
|
|
133103
|
+
buf.push('>');
|
|
133104
|
+
}
|
|
133105
|
+
return null;
|
|
133106
|
+
|
|
133107
|
+
case PROCESSING_INSTRUCTION_NODE:
|
|
133108
|
+
if (requireWellFormed && n.data.indexOf('?>') !== -1) {
|
|
133109
|
+
throw new DOMException(INVALID_STATE_ERR, 'The ProcessingInstruction data contains "?>"');
|
|
133110
|
+
}
|
|
133111
|
+
buf.push('<?', n.target, ' ', n.data, '?>');
|
|
133112
|
+
return null;
|
|
133113
|
+
|
|
133114
|
+
case ENTITY_REFERENCE_NODE:
|
|
133115
|
+
buf.push('&', n.nodeName, ';');
|
|
133116
|
+
return null;
|
|
133117
|
+
|
|
133118
|
+
//case ENTITY_NODE:
|
|
133119
|
+
//case NOTATION_NODE:
|
|
133120
|
+
default:
|
|
133121
|
+
buf.push('??', n.nodeName);
|
|
133122
|
+
return null;
|
|
132859
133123
|
}
|
|
132860
|
-
|
|
132861
|
-
|
|
132862
|
-
|
|
132863
|
-
|
|
132864
|
-
var sub = node.internalSubset;
|
|
132865
|
-
if(sub){
|
|
132866
|
-
buf.push(" [",sub,"]");
|
|
133124
|
+
},
|
|
133125
|
+
exit: function (n, childCtx) {
|
|
133126
|
+
if (childCtx && childCtx.tag) {
|
|
133127
|
+
buf.push('</', childCtx.tag, '>');
|
|
132867
133128
|
}
|
|
132868
|
-
|
|
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
|
-
}
|
|
133129
|
+
},
|
|
133130
|
+
});
|
|
132880
133131
|
}
|
|
132881
|
-
|
|
132882
|
-
|
|
132883
|
-
|
|
132884
|
-
|
|
132885
|
-
|
|
132886
|
-
|
|
132887
|
-
|
|
132888
|
-
|
|
132889
|
-
|
|
132890
|
-
|
|
132891
|
-
|
|
132892
|
-
|
|
132893
|
-
|
|
132894
|
-
|
|
132895
|
-
|
|
132896
|
-
|
|
132897
|
-
|
|
132898
|
-
|
|
132899
|
-
|
|
132900
|
-
|
|
132901
|
-
|
|
132902
|
-
|
|
132903
|
-
|
|
132904
|
-
|
|
132905
|
-
|
|
132906
|
-
|
|
132907
|
-
|
|
132908
|
-
|
|
132909
|
-
|
|
132910
|
-
|
|
132911
|
-
|
|
132912
|
-
|
|
132913
|
-
|
|
132914
|
-
|
|
132915
|
-
|
|
132916
|
-
|
|
132917
|
-
|
|
132918
|
-
var child = node.firstChild;
|
|
132919
|
-
while(child){
|
|
132920
|
-
node2.appendChild(importNode(doc,child,deep));
|
|
132921
|
-
child = child.nextSibling;
|
|
132922
|
-
}
|
|
132923
|
-
}
|
|
132924
|
-
return node2;
|
|
133132
|
+
/**
|
|
133133
|
+
* Imports a node from a different document into `doc`, creating a new copy.
|
|
133134
|
+
* Delegates to {@link walkDOM} for traversal. Each node in the subtree is shallow-cloned,
|
|
133135
|
+
* stamped with `doc` as its `ownerDocument`, and detached (`parentNode` set to `null`).
|
|
133136
|
+
* Children are imported recursively when `deep` is `true`; for {@link Attr} nodes `deep` is
|
|
133137
|
+
* always forced to `true`
|
|
133138
|
+
* because an attribute's value lives in a child text node.
|
|
133139
|
+
*
|
|
133140
|
+
* @param {Document} doc
|
|
133141
|
+
* The document that will own the imported node.
|
|
133142
|
+
* @param {Node} node
|
|
133143
|
+
* The node to import.
|
|
133144
|
+
* @param {boolean} deep
|
|
133145
|
+
* If `true`, descendants are imported recursively.
|
|
133146
|
+
* @returns {Node}
|
|
133147
|
+
* The newly imported node, now owned by `doc`.
|
|
133148
|
+
*/
|
|
133149
|
+
function importNode(doc, node, deep) {
|
|
133150
|
+
var destRoot;
|
|
133151
|
+
walkDOM(node, null, {
|
|
133152
|
+
enter: function (srcNode, destParent) {
|
|
133153
|
+
// Shallow-clone the node and stamp it into the target document.
|
|
133154
|
+
var destNode = srcNode.cloneNode(false);
|
|
133155
|
+
destNode.ownerDocument = doc;
|
|
133156
|
+
destNode.parentNode = null;
|
|
133157
|
+
// capture as the root of the imported subtree or attach to parent.
|
|
133158
|
+
if (destParent === null) {
|
|
133159
|
+
destRoot = destNode;
|
|
133160
|
+
} else {
|
|
133161
|
+
destParent.appendChild(destNode);
|
|
133162
|
+
}
|
|
133163
|
+
// ATTRIBUTE_NODE must always be imported deeply: its value lives in a child text node.
|
|
133164
|
+
var shouldDeep = srcNode.nodeType === ATTRIBUTE_NODE || deep;
|
|
133165
|
+
return shouldDeep ? destNode : null;
|
|
133166
|
+
},
|
|
133167
|
+
});
|
|
133168
|
+
return destRoot;
|
|
132925
133169
|
}
|
|
132926
133170
|
//
|
|
132927
133171
|
//var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1,
|
|
132928
133172
|
// attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
|
|
132929
|
-
function cloneNode(doc,node,deep){
|
|
132930
|
-
var
|
|
132931
|
-
|
|
132932
|
-
|
|
132933
|
-
|
|
132934
|
-
|
|
132935
|
-
|
|
132936
|
-
|
|
133173
|
+
function cloneNode(doc, node, deep) {
|
|
133174
|
+
var destRoot;
|
|
133175
|
+
walkDOM(node, null, {
|
|
133176
|
+
enter: function (srcNode, destParent) {
|
|
133177
|
+
// 1. Create a blank node of the same type and copy all scalar own properties.
|
|
133178
|
+
var destNode = new srcNode.constructor();
|
|
133179
|
+
for (var n in srcNode) {
|
|
133180
|
+
if (Object.prototype.hasOwnProperty.call(srcNode, n)) {
|
|
133181
|
+
var v = srcNode[n];
|
|
133182
|
+
if (typeof v != 'object') {
|
|
133183
|
+
if (v != destNode[n]) {
|
|
133184
|
+
destNode[n] = v;
|
|
133185
|
+
}
|
|
133186
|
+
}
|
|
132937
133187
|
}
|
|
132938
133188
|
}
|
|
132939
|
-
|
|
132940
|
-
|
|
132941
|
-
|
|
132942
|
-
|
|
132943
|
-
|
|
132944
|
-
|
|
132945
|
-
|
|
132946
|
-
|
|
132947
|
-
|
|
132948
|
-
|
|
132949
|
-
|
|
132950
|
-
|
|
132951
|
-
|
|
132952
|
-
|
|
132953
|
-
|
|
132954
|
-
|
|
132955
|
-
|
|
132956
|
-
|
|
132957
|
-
|
|
132958
|
-
|
|
132959
|
-
|
|
132960
|
-
|
|
132961
|
-
|
|
132962
|
-
|
|
132963
|
-
|
|
132964
|
-
|
|
133189
|
+
if (srcNode.childNodes) {
|
|
133190
|
+
destNode.childNodes = new NodeList();
|
|
133191
|
+
}
|
|
133192
|
+
destNode.ownerDocument = doc;
|
|
133193
|
+
// 2. Handle node-type-specific setup.
|
|
133194
|
+
// Attributes are not DOM children, so they are cloned inline here
|
|
133195
|
+
// rather than by walkDOM descent.
|
|
133196
|
+
// ATTRIBUTE_NODE forces deep=true so its own children are walked.
|
|
133197
|
+
var shouldDeep = deep;
|
|
133198
|
+
switch (destNode.nodeType) {
|
|
133199
|
+
case ELEMENT_NODE:
|
|
133200
|
+
var attrs = srcNode.attributes;
|
|
133201
|
+
var attrs2 = (destNode.attributes = new NamedNodeMap());
|
|
133202
|
+
var len = attrs.length;
|
|
133203
|
+
attrs2._ownerElement = destNode;
|
|
133204
|
+
for (var i = 0; i < len; i++) {
|
|
133205
|
+
destNode.setAttributeNode(cloneNode(doc, attrs.item(i), true));
|
|
133206
|
+
}
|
|
133207
|
+
break;
|
|
133208
|
+
case ATTRIBUTE_NODE:
|
|
133209
|
+
shouldDeep = true;
|
|
133210
|
+
}
|
|
133211
|
+
// 3. Attach to parent, or capture as the root of the cloned subtree.
|
|
133212
|
+
if (destParent !== null) {
|
|
133213
|
+
destParent.appendChild(destNode);
|
|
133214
|
+
} else {
|
|
133215
|
+
destRoot = destNode;
|
|
133216
|
+
}
|
|
133217
|
+
// 4. Return destNode as the context for children (causes walkDOM to descend),
|
|
133218
|
+
// or null to skip children (shallow clone).
|
|
133219
|
+
return shouldDeep ? destNode : null;
|
|
133220
|
+
},
|
|
133221
|
+
});
|
|
133222
|
+
return destRoot;
|
|
132965
133223
|
}
|
|
132966
133224
|
|
|
132967
133225
|
function __set__(object,key,value){
|
|
@@ -132977,49 +133235,55 @@ function requireDom$1 () {
|
|
|
132977
133235
|
}
|
|
132978
133236
|
});
|
|
132979
133237
|
|
|
132980
|
-
|
|
132981
|
-
|
|
132982
|
-
|
|
133238
|
+
/**
|
|
133239
|
+
* The text content of this node and its descendants.
|
|
133240
|
+
*
|
|
133241
|
+
* Setting `textContent` on an element or document fragment replaces all child nodes with a
|
|
133242
|
+
* single text node; on other nodes it sets `data`, `value`, and `nodeValue` directly.
|
|
133243
|
+
*
|
|
133244
|
+
* @type {string | null}
|
|
133245
|
+
* @see {@link https://dom.spec.whatwg.org/#dom-node-textcontent}
|
|
133246
|
+
*/
|
|
133247
|
+
Object.defineProperty(Node.prototype, 'textContent', {
|
|
133248
|
+
get: function () {
|
|
133249
|
+
if (this.nodeType === ELEMENT_NODE || this.nodeType === DOCUMENT_FRAGMENT_NODE) {
|
|
133250
|
+
var buf = [];
|
|
133251
|
+
walkDOM(this, null, {
|
|
133252
|
+
enter: function (n) {
|
|
133253
|
+
if (n.nodeType === ELEMENT_NODE || n.nodeType === DOCUMENT_FRAGMENT_NODE) {
|
|
133254
|
+
return true; // enter children
|
|
133255
|
+
}
|
|
133256
|
+
if (n.nodeType === PROCESSING_INSTRUCTION_NODE || n.nodeType === COMMENT_NODE) {
|
|
133257
|
+
return null; // excluded from text content
|
|
133258
|
+
}
|
|
133259
|
+
buf.push(n.nodeValue);
|
|
133260
|
+
},
|
|
133261
|
+
});
|
|
133262
|
+
return buf.join('');
|
|
133263
|
+
}
|
|
133264
|
+
return this.nodeValue;
|
|
132983
133265
|
},
|
|
132984
133266
|
|
|
132985
|
-
set:function(data){
|
|
132986
|
-
switch(this.nodeType){
|
|
132987
|
-
|
|
132988
|
-
|
|
132989
|
-
|
|
132990
|
-
|
|
132991
|
-
|
|
132992
|
-
|
|
132993
|
-
|
|
132994
|
-
|
|
132995
|
-
|
|
133267
|
+
set: function (data) {
|
|
133268
|
+
switch (this.nodeType) {
|
|
133269
|
+
case ELEMENT_NODE:
|
|
133270
|
+
case DOCUMENT_FRAGMENT_NODE:
|
|
133271
|
+
while (this.firstChild) {
|
|
133272
|
+
this.removeChild(this.firstChild);
|
|
133273
|
+
}
|
|
133274
|
+
if (data || String(data)) {
|
|
133275
|
+
this.appendChild(this.ownerDocument.createTextNode(data));
|
|
133276
|
+
}
|
|
133277
|
+
break;
|
|
132996
133278
|
|
|
132997
|
-
|
|
132998
|
-
|
|
132999
|
-
|
|
133000
|
-
|
|
133279
|
+
default:
|
|
133280
|
+
this.data = data;
|
|
133281
|
+
this.value = data;
|
|
133282
|
+
this.nodeValue = data;
|
|
133001
133283
|
}
|
|
133002
|
-
}
|
|
133284
|
+
},
|
|
133003
133285
|
});
|
|
133004
133286
|
|
|
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
133287
|
__set__ = function(object,key,value){
|
|
133024
133288
|
//console.log(value)
|
|
133025
133289
|
object['$$'+key] = value;
|
|
@@ -133035,6 +133299,7 @@ function requireDom$1 () {
|
|
|
133035
133299
|
dom$1.Element = Element;
|
|
133036
133300
|
dom$1.Node = Node;
|
|
133037
133301
|
dom$1.NodeList = NodeList;
|
|
133302
|
+
dom$1.walkDOM = walkDOM;
|
|
133038
133303
|
dom$1.XMLSerializer = XMLSerializer;
|
|
133039
133304
|
//}
|
|
133040
133305
|
return dom$1;
|
|
@@ -135825,7 +136090,7 @@ function requireSax$1 () {
|
|
|
135825
136090
|
function parseInstruction(source,start,domBuilder){
|
|
135826
136091
|
var end = source.indexOf('?>',start);
|
|
135827
136092
|
if(end){
|
|
135828
|
-
var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)
|
|
136093
|
+
var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)$/);
|
|
135829
136094
|
if(match){
|
|
135830
136095
|
match[0].length;
|
|
135831
136096
|
domBuilder.processingInstruction(match[1], match[2]) ;
|
|
@@ -188018,14 +188283,14 @@ function requireDom () {
|
|
|
188018
188283
|
ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2);
|
|
188019
188284
|
var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3);
|
|
188020
188285
|
ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4);
|
|
188021
|
-
ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
|
|
188286
|
+
var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
|
|
188022
188287
|
ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6);
|
|
188023
188288
|
ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7);
|
|
188024
188289
|
var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8);
|
|
188025
188290
|
ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9);
|
|
188026
188291
|
var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10);
|
|
188027
188292
|
//level2
|
|
188028
|
-
ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
|
|
188293
|
+
var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
|
|
188029
188294
|
ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12);
|
|
188030
188295
|
ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13);
|
|
188031
188296
|
ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14);
|
|
@@ -188075,9 +188340,10 @@ function requireDom () {
|
|
|
188075
188340
|
item: function(index) {
|
|
188076
188341
|
return index >= 0 && index < this.length ? this[index] : null;
|
|
188077
188342
|
},
|
|
188078
|
-
toString:function(isHTML,nodeFilter){
|
|
188343
|
+
toString:function(isHTML,nodeFilter,options){
|
|
188344
|
+
var requireWellFormed = !!options && !!options.requireWellFormed;
|
|
188079
188345
|
for(var buf = [], i = 0;i<this.length;i++){
|
|
188080
|
-
serializeToString(this[i],buf,isHTML,nodeFilter);
|
|
188346
|
+
serializeToString(this[i],buf,isHTML,nodeFilter,null,requireWellFormed);
|
|
188081
188347
|
}
|
|
188082
188348
|
return buf.join('');
|
|
188083
188349
|
},
|
|
@@ -188322,13 +188588,28 @@ function requireDom () {
|
|
|
188322
188588
|
/**
|
|
188323
188589
|
* Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.
|
|
188324
188590
|
*
|
|
188325
|
-
* __This
|
|
188591
|
+
* __This implementation differs from the specification:__
|
|
188326
188592
|
* - this implementation is not validating names or qualified names
|
|
188327
188593
|
* (when parsing XML strings, the SAX parser takes care of that)
|
|
188328
188594
|
*
|
|
188595
|
+
* Note: `internalSubset` can only be introduced via a direct property write to `node.internalSubset` after creation.
|
|
188596
|
+
* Creation-time validation of `publicId`, `systemId` is not enforced.
|
|
188597
|
+
* The serializer-level check covers all mutation vectors, including direct property writes.
|
|
188598
|
+
* `internalSubset` is only serialized as `[ ... ]` when both `publicId` and `systemId` are
|
|
188599
|
+
* absent (empty or `'.'`) — if either external identifier is present, `internalSubset` is
|
|
188600
|
+
* silently omitted from the serialized output.
|
|
188601
|
+
*
|
|
188329
188602
|
* @param {string} qualifiedName
|
|
188330
188603
|
* @param {string} [publicId]
|
|
188604
|
+
* The external subset public identifier. Stored verbatim including surrounding quotes.
|
|
188605
|
+
* When serialized with `requireWellFormed: true` (via the 4th-parameter options object),
|
|
188606
|
+
* throws `DOMException` with code `INVALID_STATE_ERR` if the value is non-empty and does
|
|
188607
|
+
* not match the XML `PubidLiteral` production (W3C DOM Parsing §3.2.1.3; XML 1.0 [12]).
|
|
188331
188608
|
* @param {string} [systemId]
|
|
188609
|
+
* The external subset system identifier. Stored verbatim including surrounding quotes.
|
|
188610
|
+
* When serialized with `requireWellFormed: true`, throws `DOMException` with code
|
|
188611
|
+
* `INVALID_STATE_ERR` if the value is non-empty and does not match the XML `SystemLiteral`
|
|
188612
|
+
* production (W3C DOM Parsing §3.2.1.3; XML 1.0 [11]).
|
|
188332
188613
|
* @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation
|
|
188333
188614
|
* or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`
|
|
188334
188615
|
*
|
|
@@ -188394,18 +188675,44 @@ function requireDom () {
|
|
|
188394
188675
|
return cloneNode(this.ownerDocument||this,this,deep);
|
|
188395
188676
|
},
|
|
188396
188677
|
// Modified in DOM Level 2:
|
|
188397
|
-
|
|
188398
|
-
|
|
188399
|
-
|
|
188400
|
-
|
|
188401
|
-
|
|
188402
|
-
|
|
188403
|
-
|
|
188404
|
-
|
|
188405
|
-
|
|
188406
|
-
|
|
188407
|
-
|
|
188408
|
-
|
|
188678
|
+
/**
|
|
188679
|
+
* Puts the specified node and all of its subtree into a "normalized" form. In a normalized
|
|
188680
|
+
* subtree, no text nodes in the subtree are empty and there are no adjacent text nodes.
|
|
188681
|
+
*
|
|
188682
|
+
* Specifically, this method merges any adjacent text nodes (i.e., nodes for which `nodeType`
|
|
188683
|
+
* is `TEXT_NODE`) into a single node with the combined data. It also removes any empty text
|
|
188684
|
+
* nodes.
|
|
188685
|
+
*
|
|
188686
|
+
* This method iteratively traverses all child nodes to normalize all descendant nodes within
|
|
188687
|
+
* the subtree.
|
|
188688
|
+
*
|
|
188689
|
+
* @throws {DOMException}
|
|
188690
|
+
* May throw a DOMException if operations within removeChild or appendData (which are
|
|
188691
|
+
* potentially invoked in this method) do not meet their specific constraints.
|
|
188692
|
+
* @see {@link Node.removeChild}
|
|
188693
|
+
* @see {@link CharacterData.appendData}
|
|
188694
|
+
* @see ../docs/walk-dom.md.
|
|
188695
|
+
*/
|
|
188696
|
+
normalize: function () {
|
|
188697
|
+
walkDOM(this, null, {
|
|
188698
|
+
enter: function (node) {
|
|
188699
|
+
// Merge adjacent text children of node before walkDOM schedules them.
|
|
188700
|
+
// walkDOM reads lastChild/previousSibling after enter returns, so the
|
|
188701
|
+
// surviving post-merge children are what it descends into.
|
|
188702
|
+
var child = node.firstChild;
|
|
188703
|
+
while (child) {
|
|
188704
|
+
var next = child.nextSibling;
|
|
188705
|
+
if (next !== null && next.nodeType === TEXT_NODE && child.nodeType === TEXT_NODE) {
|
|
188706
|
+
node.removeChild(next);
|
|
188707
|
+
child.appendData(next.data);
|
|
188708
|
+
// Do not advance child: re-check new nextSibling for another text run
|
|
188709
|
+
} else {
|
|
188710
|
+
child = next;
|
|
188711
|
+
}
|
|
188712
|
+
}
|
|
188713
|
+
return true; // descend into surviving children
|
|
188714
|
+
},
|
|
188715
|
+
});
|
|
188409
188716
|
},
|
|
188410
188717
|
// Introduced in DOM Level 2:
|
|
188411
188718
|
isSupported:function(feature, version){
|
|
@@ -188481,21 +188788,103 @@ function requireDom () {
|
|
|
188481
188788
|
copy(NodeType,Node.prototype);
|
|
188482
188789
|
|
|
188483
188790
|
/**
|
|
188484
|
-
* @param
|
|
188485
|
-
*
|
|
188791
|
+
* @param {Node} node
|
|
188792
|
+
* Root of the subtree to visit.
|
|
188793
|
+
* @param {function(Node): boolean} callback
|
|
188794
|
+
* Called for each node in depth-first pre-order. Return a truthy value to stop traversal early.
|
|
188795
|
+
* @return {boolean} `true` if traversal was aborted by the callback, `false` otherwise.
|
|
188486
188796
|
*/
|
|
188487
|
-
function _visitNode(node,callback){
|
|
188488
|
-
|
|
188489
|
-
return true;
|
|
188490
|
-
}
|
|
188491
|
-
if(node = node.firstChild){
|
|
188492
|
-
do{
|
|
188493
|
-
if(_visitNode(node,callback)){return true}
|
|
188494
|
-
}while(node=node.nextSibling)
|
|
188495
|
-
}
|
|
188797
|
+
function _visitNode(node, callback) {
|
|
188798
|
+
return walkDOM(node, null, { enter: function (n) { return callback(n) ? walkDOM.STOP : true; } }) === walkDOM.STOP;
|
|
188496
188799
|
}
|
|
188497
188800
|
|
|
188801
|
+
/**
|
|
188802
|
+
* Depth-first pre/post-order DOM tree walker.
|
|
188803
|
+
*
|
|
188804
|
+
* Visits every node in the subtree rooted at `node`. For each node:
|
|
188805
|
+
*
|
|
188806
|
+
* 1. Calls `callbacks.enter(node, context)` before descending into the node's children. The
|
|
188807
|
+
* return value becomes the `context` passed to each child's `enter` call and to the matching
|
|
188808
|
+
* `exit` call.
|
|
188809
|
+
* 2. If `enter` returns `null` or `undefined`, the node's children are skipped;
|
|
188810
|
+
* sibling traversal continues normally.
|
|
188811
|
+
* 3. If `enter` returns `walkDOM.STOP`, the entire traversal is aborted immediately — no
|
|
188812
|
+
* further `enter` or `exit` calls are made.
|
|
188813
|
+
* 4. `lastChild` and `previousSibling` are read **after** `enter` returns, so `enter` may
|
|
188814
|
+
* safely modify the node's own child list before the walker descends. Modifying siblings of
|
|
188815
|
+
* the current node or any other part of the tree produces unpredictable results: nodes already
|
|
188816
|
+
* queued on the stack are visited regardless of DOM changes, and newly inserted nodes outside
|
|
188817
|
+
* the current child list are never visited.
|
|
188818
|
+
* 5. Calls `callbacks.exit(node, context)` (if provided) after all of a node's children have
|
|
188819
|
+
* been visited, passing the same `context` that `enter`
|
|
188820
|
+
* returned for that node.
|
|
188821
|
+
*
|
|
188822
|
+
* This implementation uses an explicit stack and does not recurse — it is safe on arbitrarily
|
|
188823
|
+
* deep trees.
|
|
188824
|
+
*
|
|
188825
|
+
* @param {Node} node
|
|
188826
|
+
* Root of the subtree to walk.
|
|
188827
|
+
* @param {*} context
|
|
188828
|
+
* Initial context value passed to the root node's `enter`.
|
|
188829
|
+
* @param {{ enter: function(Node, *): *, exit?: function(Node, *): void }} callbacks
|
|
188830
|
+
* @returns {void | walkDOM.STOP}
|
|
188831
|
+
* @see ../docs/walk-dom.md.
|
|
188832
|
+
*/
|
|
188833
|
+
function walkDOM(node, context, callbacks) {
|
|
188834
|
+
// Each stack frame is {node, context, phase}:
|
|
188835
|
+
// walkDOM.ENTER — call enter, then push children
|
|
188836
|
+
// walkDOM.EXIT — call exit
|
|
188837
|
+
var stack = [{ node: node, context: context, phase: walkDOM.ENTER }];
|
|
188838
|
+
while (stack.length > 0) {
|
|
188839
|
+
var frame = stack.pop();
|
|
188840
|
+
if (frame.phase === walkDOM.ENTER) {
|
|
188841
|
+
var childContext = callbacks.enter(frame.node, frame.context);
|
|
188842
|
+
if (childContext === walkDOM.STOP) {
|
|
188843
|
+
return walkDOM.STOP;
|
|
188844
|
+
}
|
|
188845
|
+
// Push exit frame before children so it fires after all children are processed (Last In First Out)
|
|
188846
|
+
stack.push({ node: frame.node, context: childContext, phase: walkDOM.EXIT });
|
|
188847
|
+
if (childContext === null || childContext === undefined) {
|
|
188848
|
+
continue; // skip children
|
|
188849
|
+
}
|
|
188850
|
+
// lastChild is read after enter returns, so enter may modify the child list.
|
|
188851
|
+
var child = frame.node.lastChild;
|
|
188852
|
+
// Traverse from lastChild backwards so that pushing onto the stack
|
|
188853
|
+
// naturally yields firstChild on top (processed first).
|
|
188854
|
+
while (child) {
|
|
188855
|
+
stack.push({ node: child, context: childContext, phase: walkDOM.ENTER });
|
|
188856
|
+
child = child.previousSibling;
|
|
188857
|
+
}
|
|
188858
|
+
} else {
|
|
188859
|
+
// frame.phase === walkDOM.EXIT
|
|
188860
|
+
if (callbacks.exit) {
|
|
188861
|
+
callbacks.exit(frame.node, frame.context);
|
|
188862
|
+
}
|
|
188863
|
+
}
|
|
188864
|
+
}
|
|
188865
|
+
}
|
|
188498
188866
|
|
|
188867
|
+
/**
|
|
188868
|
+
* Sentinel value returned from a `walkDOM` `enter` callback to abort the entire traversal
|
|
188869
|
+
* immediately.
|
|
188870
|
+
*
|
|
188871
|
+
* @type {symbol}
|
|
188872
|
+
*/
|
|
188873
|
+
walkDOM.STOP = Symbol('walkDOM.STOP');
|
|
188874
|
+
/**
|
|
188875
|
+
* Phase constant for a stack frame that has not yet been visited.
|
|
188876
|
+
* The `enter` callback is called and children are scheduled.
|
|
188877
|
+
*
|
|
188878
|
+
* @type {number}
|
|
188879
|
+
*/
|
|
188880
|
+
walkDOM.ENTER = 0;
|
|
188881
|
+
/**
|
|
188882
|
+
* Phase constant for a stack frame whose subtree has been fully visited.
|
|
188883
|
+
* The `exit` callback is called.
|
|
188884
|
+
*
|
|
188885
|
+
* @type {number}
|
|
188886
|
+
*/
|
|
188887
|
+
walkDOM.EXIT = 1;
|
|
188499
188888
|
|
|
188500
188889
|
function Document(){
|
|
188501
188890
|
this.ownerDocument = this;
|
|
@@ -189099,12 +189488,44 @@ function requireDom () {
|
|
|
189099
189488
|
node.appendData(data);
|
|
189100
189489
|
return node;
|
|
189101
189490
|
},
|
|
189491
|
+
/**
|
|
189492
|
+
* Returns a new CDATASection node whose data is `data`.
|
|
189493
|
+
*
|
|
189494
|
+
* __This implementation differs from the specification:__
|
|
189495
|
+
* - calling this method on an HTML document does not throw `NotSupportedError`.
|
|
189496
|
+
*
|
|
189497
|
+
* @param {string} data
|
|
189498
|
+
* @returns {CDATASection}
|
|
189499
|
+
* @throws DOMException with code `INVALID_CHARACTER_ERR` if `data` contains `"]]>"`.
|
|
189500
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createCDATASection
|
|
189501
|
+
* @see https://dom.spec.whatwg.org/#dom-document-createcdatasection
|
|
189502
|
+
*/
|
|
189102
189503
|
createCDATASection : function(data){
|
|
189504
|
+
if (data.indexOf(']]>') !== -1) {
|
|
189505
|
+
throw new DOMException(INVALID_CHARACTER_ERR, 'data contains "]]>"');
|
|
189506
|
+
}
|
|
189103
189507
|
var node = new CDATASection();
|
|
189104
189508
|
node.ownerDocument = this;
|
|
189105
189509
|
node.appendData(data);
|
|
189106
189510
|
return node;
|
|
189107
189511
|
},
|
|
189512
|
+
/**
|
|
189513
|
+
* Returns a ProcessingInstruction node whose target is target and data is data.
|
|
189514
|
+
*
|
|
189515
|
+
* __This implementation differs from the specification:__
|
|
189516
|
+
* - it does not do any input validation on the arguments and doesn't throw "InvalidCharacterError".
|
|
189517
|
+
*
|
|
189518
|
+
* Note: When the resulting document is serialized with `requireWellFormed: true`, the
|
|
189519
|
+
* serializer throws with code `INVALID_STATE_ERR` if `.data` contains `?>` (W3C DOM Parsing
|
|
189520
|
+
* §3.2.1.7). Without that option the data is emitted verbatim.
|
|
189521
|
+
*
|
|
189522
|
+
* @param {string} target
|
|
189523
|
+
* @param {string} data
|
|
189524
|
+
* @returns {ProcessingInstruction}
|
|
189525
|
+
* @see https://developer.mozilla.org/docs/Web/API/Document/createProcessingInstruction
|
|
189526
|
+
* @see https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
|
|
189527
|
+
* @see https://www.w3.org/TR/DOM-Parsing/#dfn-concept-serialize-xml §3.2.1.7
|
|
189528
|
+
*/
|
|
189108
189529
|
createProcessingInstruction : function(target,data){
|
|
189109
189530
|
var node = new ProcessingInstruction();
|
|
189110
189531
|
node.ownerDocument = this;
|
|
@@ -189330,6 +189751,19 @@ function requireDom () {
|
|
|
189330
189751
|
_extends(CDATASection,CharacterData);
|
|
189331
189752
|
|
|
189332
189753
|
|
|
189754
|
+
/**
|
|
189755
|
+
* Represents a DocumentType node (the `<!DOCTYPE ...>` declaration).
|
|
189756
|
+
*
|
|
189757
|
+
* `publicId`, `systemId`, and `internalSubset` are plain own-property assignments.
|
|
189758
|
+
* xmldom does not enforce the `readonly` constraint declared by the WHATWG DOM spec —
|
|
189759
|
+
* direct property writes succeed silently. Values are serialized verbatim when
|
|
189760
|
+
* `requireWellFormed` is false (the default). When the serializer is invoked with
|
|
189761
|
+
* `requireWellFormed: true` (via the 4th-parameter options object), it validates each
|
|
189762
|
+
* field and throws `DOMException` with code `INVALID_STATE_ERR` on invalid values.
|
|
189763
|
+
*
|
|
189764
|
+
* @class
|
|
189765
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DocumentType MDN
|
|
189766
|
+
*/
|
|
189333
189767
|
function DocumentType() {
|
|
189334
189768
|
} DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
|
|
189335
189769
|
_extends(DocumentType,Node);
|
|
@@ -189357,11 +189791,48 @@ function requireDom () {
|
|
|
189357
189791
|
ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
|
|
189358
189792
|
_extends(ProcessingInstruction,Node);
|
|
189359
189793
|
function XMLSerializer(){}
|
|
189360
|
-
|
|
189361
|
-
|
|
189794
|
+
/**
|
|
189795
|
+
* Returns the result of serializing `node` to XML.
|
|
189796
|
+
*
|
|
189797
|
+
* When `options.requireWellFormed` is `true`, the serializer throws for content that would
|
|
189798
|
+
* produce ill-formed XML.
|
|
189799
|
+
*
|
|
189800
|
+
* __This implementation differs from the specification:__
|
|
189801
|
+
* - CDATASection nodes whose data contains `]]>` are serialized by splitting the section
|
|
189802
|
+
* at each `]]>` occurrence (following W3C DOM Level 3 Core `split-cdata-sections`
|
|
189803
|
+
* default behaviour) unless `requireWellFormed` is `true`.
|
|
189804
|
+
* - when `requireWellFormed` is `true`, `DOMException` with code `INVALID_STATE_ERR`
|
|
189805
|
+
* is only thrown to prevent injection vectors, not for all the spec mandated checks.
|
|
189806
|
+
*
|
|
189807
|
+
* @param {Node} node
|
|
189808
|
+
* @param {boolean} [isHtml]
|
|
189809
|
+
* @param {function} [nodeFilter]
|
|
189810
|
+
* @param {Object} [options]
|
|
189811
|
+
* @param {boolean} [options.requireWellFormed=false]
|
|
189812
|
+
* When `true`, throws for content that would produce ill-formed XML.
|
|
189813
|
+
* @returns {string}
|
|
189814
|
+
* @throws {DOMException}
|
|
189815
|
+
* With code `INVALID_STATE_ERR` when `requireWellFormed` is `true` and:
|
|
189816
|
+
* - a CDATASection node's data contains `"]]>"`,
|
|
189817
|
+
* - a Comment node's data contains `"-->"` (bare `"--"` does not throw on this branch),
|
|
189818
|
+
* - a ProcessingInstruction's data contains `"?>"`,
|
|
189819
|
+
* - a DocumentType's `publicId` is non-empty and does not match the XML `PubidLiteral`
|
|
189820
|
+
* production,
|
|
189821
|
+
* - a DocumentType's `systemId` is non-empty and does not match the XML `SystemLiteral`
|
|
189822
|
+
* production, or
|
|
189823
|
+
* - a DocumentType's `internalSubset` contains `"]>"`.
|
|
189824
|
+
* Note: xmldom does not enforce `readonly` on DocumentType fields — direct property
|
|
189825
|
+
* writes succeed and are covered by the serializer-level checks above.
|
|
189826
|
+
* @see https://html.spec.whatwg.org/#dom-xmlserializer-serializetostring
|
|
189827
|
+
* @see https://w3c.github.io/DOM-Parsing/#xml-serialization
|
|
189828
|
+
* @see https://github.com/w3c/DOM-Parsing/issues/84
|
|
189829
|
+
*/
|
|
189830
|
+
XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter,options){
|
|
189831
|
+
return nodeSerializeToString.call(node,isHtml,nodeFilter,options);
|
|
189362
189832
|
};
|
|
189363
189833
|
Node.prototype.toString = nodeSerializeToString;
|
|
189364
|
-
function nodeSerializeToString(isHtml,nodeFilter){
|
|
189834
|
+
function nodeSerializeToString(isHtml,nodeFilter,options){
|
|
189835
|
+
var requireWellFormed = !!options && !!options.requireWellFormed;
|
|
189365
189836
|
var buf = [];
|
|
189366
189837
|
var refNode = this.nodeType == 9 && this.documentElement || this;
|
|
189367
189838
|
var prefix = refNode.prefix;
|
|
@@ -189378,7 +189849,7 @@ function requireDom () {
|
|
|
189378
189849
|
];
|
|
189379
189850
|
}
|
|
189380
189851
|
}
|
|
189381
|
-
serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces);
|
|
189852
|
+
serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces,requireWellFormed);
|
|
189382
189853
|
//console.log('###',this.nodeType,uri,prefix,buf.join(''))
|
|
189383
189854
|
return buf.join('');
|
|
189384
189855
|
}
|
|
@@ -189427,271 +189898,323 @@ function requireDom () {
|
|
|
189427
189898
|
buf.push(' ', qualifiedName, '="', value.replace(/[<>&"\t\n\r]/g, _xmlEncoder), '"');
|
|
189428
189899
|
}
|
|
189429
189900
|
|
|
189430
|
-
function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
|
|
189901
|
+
function serializeToString(node, buf, isHTML, nodeFilter, visibleNamespaces, requireWellFormed) {
|
|
189431
189902
|
if (!visibleNamespaces) {
|
|
189432
189903
|
visibleNamespaces = [];
|
|
189433
189904
|
}
|
|
189434
|
-
|
|
189435
|
-
|
|
189436
|
-
|
|
189437
|
-
|
|
189438
|
-
|
|
189439
|
-
|
|
189440
|
-
|
|
189441
|
-
|
|
189442
|
-
|
|
189443
|
-
|
|
189444
|
-
|
|
189445
|
-
//buf.sort.apply(attrs, attributeSorter);
|
|
189446
|
-
}
|
|
189447
|
-
|
|
189448
|
-
switch(node.nodeType){
|
|
189449
|
-
case ELEMENT_NODE:
|
|
189450
|
-
var attrs = node.attributes;
|
|
189451
|
-
var len = attrs.length;
|
|
189452
|
-
var child = node.firstChild;
|
|
189453
|
-
var nodeName = node.tagName;
|
|
189454
|
-
|
|
189455
|
-
isHTML = NAMESPACE.isHTML(node.namespaceURI) || isHTML;
|
|
189456
|
-
|
|
189457
|
-
var prefixedNodeName = nodeName;
|
|
189458
|
-
if (!isHTML && !node.prefix && node.namespaceURI) {
|
|
189459
|
-
var defaultNS;
|
|
189460
|
-
// lookup current default ns from `xmlns` attribute
|
|
189461
|
-
for (var ai = 0; ai < attrs.length; ai++) {
|
|
189462
|
-
if (attrs.item(ai).name === 'xmlns') {
|
|
189463
|
-
defaultNS = attrs.item(ai).value;
|
|
189464
|
-
break
|
|
189465
|
-
}
|
|
189466
|
-
}
|
|
189467
|
-
if (!defaultNS) {
|
|
189468
|
-
// lookup current default ns in visibleNamespaces
|
|
189469
|
-
for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
|
|
189470
|
-
var namespace = visibleNamespaces[nsi];
|
|
189471
|
-
if (namespace.prefix === '' && namespace.namespace === node.namespaceURI) {
|
|
189472
|
-
defaultNS = namespace.namespace;
|
|
189473
|
-
break
|
|
189905
|
+
walkDOM(node, { ns: visibleNamespaces, isHTML: isHTML }, {
|
|
189906
|
+
enter: function (n, ctx) {
|
|
189907
|
+
var ns = ctx.ns;
|
|
189908
|
+
var html = ctx.isHTML;
|
|
189909
|
+
|
|
189910
|
+
if (nodeFilter) {
|
|
189911
|
+
n = nodeFilter(n);
|
|
189912
|
+
if (n) {
|
|
189913
|
+
if (typeof n == 'string') {
|
|
189914
|
+
buf.push(n);
|
|
189915
|
+
return null;
|
|
189474
189916
|
}
|
|
189917
|
+
} else {
|
|
189918
|
+
return null;
|
|
189475
189919
|
}
|
|
189476
189920
|
}
|
|
189477
|
-
|
|
189478
|
-
|
|
189479
|
-
|
|
189480
|
-
|
|
189481
|
-
|
|
189482
|
-
|
|
189921
|
+
|
|
189922
|
+
switch (n.nodeType) {
|
|
189923
|
+
case ELEMENT_NODE:
|
|
189924
|
+
var attrs = n.attributes;
|
|
189925
|
+
var len = attrs.length;
|
|
189926
|
+
var nodeName = n.tagName;
|
|
189927
|
+
|
|
189928
|
+
html = NAMESPACE.isHTML(n.namespaceURI) || html;
|
|
189929
|
+
|
|
189930
|
+
var prefixedNodeName = nodeName;
|
|
189931
|
+
if (!html && !n.prefix && n.namespaceURI) {
|
|
189932
|
+
var defaultNS;
|
|
189933
|
+
// lookup current default ns from `xmlns` attribute
|
|
189934
|
+
for (var ai = 0; ai < attrs.length; ai++) {
|
|
189935
|
+
if (attrs.item(ai).name === 'xmlns') {
|
|
189936
|
+
defaultNS = attrs.item(ai).value;
|
|
189937
|
+
break;
|
|
189938
|
+
}
|
|
189939
|
+
}
|
|
189940
|
+
if (!defaultNS) {
|
|
189941
|
+
// lookup current default ns in visibleNamespaces
|
|
189942
|
+
for (var nsi = ns.length - 1; nsi >= 0; nsi--) {
|
|
189943
|
+
var nsEntry = ns[nsi];
|
|
189944
|
+
if (nsEntry.prefix === '' && nsEntry.namespace === n.namespaceURI) {
|
|
189945
|
+
defaultNS = nsEntry.namespace;
|
|
189946
|
+
break;
|
|
189947
|
+
}
|
|
189948
|
+
}
|
|
189949
|
+
}
|
|
189950
|
+
if (defaultNS !== n.namespaceURI) {
|
|
189951
|
+
for (var nsi = ns.length - 1; nsi >= 0; nsi--) {
|
|
189952
|
+
var nsEntry = ns[nsi];
|
|
189953
|
+
if (nsEntry.namespace === n.namespaceURI) {
|
|
189954
|
+
if (nsEntry.prefix) {
|
|
189955
|
+
prefixedNodeName = nsEntry.prefix + ':' + nodeName;
|
|
189956
|
+
}
|
|
189957
|
+
break;
|
|
189958
|
+
}
|
|
189959
|
+
}
|
|
189483
189960
|
}
|
|
189484
|
-
break
|
|
189485
189961
|
}
|
|
189486
|
-
}
|
|
189487
|
-
}
|
|
189488
|
-
}
|
|
189489
189962
|
|
|
189490
|
-
|
|
189963
|
+
buf.push('<', prefixedNodeName);
|
|
189964
|
+
|
|
189965
|
+
// Build a fresh namespace snapshot for this element's children.
|
|
189966
|
+
// The slice prevents sibling elements from inheriting each other's declarations.
|
|
189967
|
+
var childNs = ns.slice();
|
|
189968
|
+
for (var i = 0; i < len; i++) {
|
|
189969
|
+
var attr = attrs.item(i);
|
|
189970
|
+
if (attr.prefix == 'xmlns') {
|
|
189971
|
+
childNs.push({ prefix: attr.localName, namespace: attr.value });
|
|
189972
|
+
} else if (attr.nodeName == 'xmlns') {
|
|
189973
|
+
childNs.push({ prefix: '', namespace: attr.value });
|
|
189974
|
+
}
|
|
189975
|
+
}
|
|
189491
189976
|
|
|
189492
|
-
|
|
189493
|
-
|
|
189494
|
-
|
|
189495
|
-
|
|
189496
|
-
|
|
189497
|
-
|
|
189498
|
-
|
|
189499
|
-
|
|
189500
|
-
|
|
189977
|
+
for (var i = 0; i < len; i++) {
|
|
189978
|
+
var attr = attrs.item(i);
|
|
189979
|
+
if (needNamespaceDefine(attr, html, childNs)) {
|
|
189980
|
+
var attrPrefix = attr.prefix || '';
|
|
189981
|
+
var uri = attr.namespaceURI;
|
|
189982
|
+
addSerializedAttribute(buf, attrPrefix ? 'xmlns:' + attrPrefix : 'xmlns', uri);
|
|
189983
|
+
childNs.push({ prefix: attrPrefix, namespace: uri });
|
|
189984
|
+
}
|
|
189985
|
+
// Apply nodeFilter and serialize the attribute.
|
|
189986
|
+
var filteredAttr = nodeFilter ? nodeFilter(attr) : attr;
|
|
189987
|
+
if (filteredAttr) {
|
|
189988
|
+
if (typeof filteredAttr === 'string') {
|
|
189989
|
+
buf.push(filteredAttr);
|
|
189990
|
+
} else {
|
|
189991
|
+
addSerializedAttribute(buf, filteredAttr.name, filteredAttr.value);
|
|
189992
|
+
}
|
|
189993
|
+
}
|
|
189994
|
+
}
|
|
189501
189995
|
|
|
189502
|
-
|
|
189503
|
-
|
|
189504
|
-
|
|
189505
|
-
|
|
189506
|
-
|
|
189507
|
-
|
|
189508
|
-
|
|
189509
|
-
}
|
|
189510
|
-
serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
|
|
189511
|
-
}
|
|
189996
|
+
// add namespace for current node
|
|
189997
|
+
if (nodeName === prefixedNodeName && needNamespaceDefine(n, html, childNs)) {
|
|
189998
|
+
var nodePrefix = n.prefix || '';
|
|
189999
|
+
var uri = n.namespaceURI;
|
|
190000
|
+
addSerializedAttribute(buf, nodePrefix ? 'xmlns:' + nodePrefix : 'xmlns', uri);
|
|
190001
|
+
childNs.push({ prefix: nodePrefix, namespace: uri });
|
|
190002
|
+
}
|
|
189512
190003
|
|
|
189513
|
-
|
|
189514
|
-
|
|
189515
|
-
|
|
189516
|
-
|
|
189517
|
-
|
|
189518
|
-
|
|
189519
|
-
|
|
190004
|
+
var child = n.firstChild;
|
|
190005
|
+
if (child || html && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)) {
|
|
190006
|
+
buf.push('>');
|
|
190007
|
+
if (html && /^script$/i.test(nodeName)) {
|
|
190008
|
+
// Inline serialization for <script> children; return null to skip walkDOM descent.
|
|
190009
|
+
while (child) {
|
|
190010
|
+
if (child.data) {
|
|
190011
|
+
buf.push(child.data);
|
|
190012
|
+
} else {
|
|
190013
|
+
serializeToString(child, buf, html, nodeFilter, childNs.slice(), requireWellFormed);
|
|
190014
|
+
}
|
|
190015
|
+
child = child.nextSibling;
|
|
190016
|
+
}
|
|
190017
|
+
buf.push('</', nodeName, '>');
|
|
190018
|
+
return null;
|
|
190019
|
+
}
|
|
190020
|
+
// Return child context; walkDOM descends and exit emits the closing tag.
|
|
190021
|
+
return { ns: childNs, isHTML: html, tag: prefixedNodeName };
|
|
190022
|
+
} else {
|
|
190023
|
+
buf.push('/>');
|
|
190024
|
+
return null;
|
|
190025
|
+
}
|
|
189520
190026
|
|
|
189521
|
-
|
|
189522
|
-
|
|
189523
|
-
|
|
189524
|
-
|
|
189525
|
-
|
|
189526
|
-
|
|
189527
|
-
|
|
189528
|
-
|
|
189529
|
-
|
|
190027
|
+
case DOCUMENT_NODE:
|
|
190028
|
+
case DOCUMENT_FRAGMENT_NODE:
|
|
190029
|
+
// Descend into children; exit is a no-op (tag is null).
|
|
190030
|
+
return { ns: ns.slice(), isHTML: html, tag: null };
|
|
190031
|
+
|
|
190032
|
+
case ATTRIBUTE_NODE:
|
|
190033
|
+
addSerializedAttribute(buf, n.name, n.value);
|
|
190034
|
+
return null;
|
|
190035
|
+
|
|
190036
|
+
case TEXT_NODE:
|
|
190037
|
+
/**
|
|
190038
|
+
* The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
|
|
190039
|
+
* except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section.
|
|
190040
|
+
* If they are needed elsewhere, they must be escaped using either numeric character references or the strings
|
|
190041
|
+
* `&` and `<` respectively.
|
|
190042
|
+
* The right angle bracket (>) may be represented using the string " > ", and must, for compatibility,
|
|
190043
|
+
* be escaped using either `>` or a character reference when it appears in the string `]]>` in content,
|
|
190044
|
+
* when that string is not marking the end of a CDATA section.
|
|
190045
|
+
*
|
|
190046
|
+
* In the content of elements, character data is any string of characters
|
|
190047
|
+
* which does not contain the start-delimiter of any markup
|
|
190048
|
+
* and does not include the CDATA-section-close delimiter, `]]>`.
|
|
190049
|
+
*
|
|
190050
|
+
* @see https://www.w3.org/TR/xml/#NT-CharData
|
|
190051
|
+
* @see https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node
|
|
190052
|
+
*/
|
|
190053
|
+
buf.push(n.data.replace(/[<&>]/g, _xmlEncoder));
|
|
190054
|
+
return null;
|
|
190055
|
+
|
|
190056
|
+
case CDATA_SECTION_NODE:
|
|
190057
|
+
if (requireWellFormed && n.data.indexOf(']]>') !== -1) {
|
|
190058
|
+
throw new DOMException(INVALID_STATE_ERR, 'The CDATASection data contains "]]>"');
|
|
189530
190059
|
}
|
|
189531
|
-
|
|
189532
|
-
|
|
189533
|
-
|
|
189534
|
-
|
|
189535
|
-
|
|
189536
|
-
|
|
189537
|
-
|
|
189538
|
-
|
|
189539
|
-
|
|
189540
|
-
|
|
189541
|
-
|
|
189542
|
-
|
|
189543
|
-
|
|
189544
|
-
|
|
189545
|
-
|
|
189546
|
-
|
|
189547
|
-
|
|
189548
|
-
|
|
189549
|
-
|
|
189550
|
-
|
|
189551
|
-
|
|
189552
|
-
|
|
189553
|
-
|
|
189554
|
-
|
|
189555
|
-
|
|
189556
|
-
|
|
189557
|
-
|
|
189558
|
-
|
|
189559
|
-
|
|
189560
|
-
|
|
189561
|
-
|
|
189562
|
-
|
|
189563
|
-
|
|
189564
|
-
|
|
189565
|
-
|
|
189566
|
-
|
|
189567
|
-
|
|
189568
|
-
|
|
189569
|
-
|
|
189570
|
-
|
|
189571
|
-
|
|
189572
|
-
|
|
189573
|
-
|
|
189574
|
-
|
|
189575
|
-
|
|
189576
|
-
|
|
189577
|
-
|
|
189578
|
-
|
|
189579
|
-
|
|
189580
|
-
|
|
189581
|
-
|
|
189582
|
-
|
|
189583
|
-
|
|
189584
|
-
|
|
189585
|
-
|
|
189586
|
-
|
|
189587
|
-
|
|
189588
|
-
|
|
190060
|
+
buf.push('<![CDATA[', n.data.replace(/]]>/g, ']]]]><![CDATA[>'), ']]>');
|
|
190061
|
+
return null;
|
|
190062
|
+
|
|
190063
|
+
case COMMENT_NODE:
|
|
190064
|
+
if (requireWellFormed && n.data.indexOf('-->') !== -1) {
|
|
190065
|
+
throw new DOMException(INVALID_STATE_ERR, 'The comment node data contains "-->"');
|
|
190066
|
+
}
|
|
190067
|
+
buf.push('<!--', n.data, '-->');
|
|
190068
|
+
return null;
|
|
190069
|
+
|
|
190070
|
+
case DOCUMENT_TYPE_NODE:
|
|
190071
|
+
if (requireWellFormed) {
|
|
190072
|
+
if (n.publicId && !/^("[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%']*"|'[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%'"]*')$/.test(n.publicId)) {
|
|
190073
|
+
throw new DOMException(INVALID_STATE_ERR, 'DocumentType publicId is not a valid PubidLiteral');
|
|
190074
|
+
}
|
|
190075
|
+
if (n.systemId && !/^("[^"]*"|'[^']*')$/.test(n.systemId)) {
|
|
190076
|
+
throw new DOMException(INVALID_STATE_ERR, 'DocumentType systemId is not a valid SystemLiteral');
|
|
190077
|
+
}
|
|
190078
|
+
if (n.internalSubset && n.internalSubset.indexOf(']>') !== -1) {
|
|
190079
|
+
throw new DOMException(INVALID_STATE_ERR, 'DocumentType internalSubset contains "]>"');
|
|
190080
|
+
}
|
|
190081
|
+
}
|
|
190082
|
+
var pubid = n.publicId;
|
|
190083
|
+
var sysid = n.systemId;
|
|
190084
|
+
buf.push('<!DOCTYPE ', n.name);
|
|
190085
|
+
if (pubid) {
|
|
190086
|
+
buf.push(' PUBLIC ', pubid);
|
|
190087
|
+
if (sysid && sysid != '.') {
|
|
190088
|
+
buf.push(' ', sysid);
|
|
190089
|
+
}
|
|
190090
|
+
buf.push('>');
|
|
190091
|
+
} else if (sysid && sysid != '.') {
|
|
190092
|
+
buf.push(' SYSTEM ', sysid, '>');
|
|
190093
|
+
} else {
|
|
190094
|
+
var sub = n.internalSubset;
|
|
190095
|
+
if (sub) {
|
|
190096
|
+
buf.push(' [', sub, ']');
|
|
190097
|
+
}
|
|
190098
|
+
buf.push('>');
|
|
190099
|
+
}
|
|
190100
|
+
return null;
|
|
190101
|
+
|
|
190102
|
+
case PROCESSING_INSTRUCTION_NODE:
|
|
190103
|
+
if (requireWellFormed && n.data.indexOf('?>') !== -1) {
|
|
190104
|
+
throw new DOMException(INVALID_STATE_ERR, 'The ProcessingInstruction data contains "?>"');
|
|
190105
|
+
}
|
|
190106
|
+
buf.push('<?', n.target, ' ', n.data, '?>');
|
|
190107
|
+
return null;
|
|
190108
|
+
|
|
190109
|
+
case ENTITY_REFERENCE_NODE:
|
|
190110
|
+
buf.push('&', n.nodeName, ';');
|
|
190111
|
+
return null;
|
|
190112
|
+
|
|
190113
|
+
//case ENTITY_NODE:
|
|
190114
|
+
//case NOTATION_NODE:
|
|
190115
|
+
default:
|
|
190116
|
+
buf.push('??', n.nodeName);
|
|
190117
|
+
return null;
|
|
189589
190118
|
}
|
|
189590
|
-
|
|
189591
|
-
|
|
189592
|
-
|
|
189593
|
-
|
|
189594
|
-
var sub = node.internalSubset;
|
|
189595
|
-
if(sub){
|
|
189596
|
-
buf.push(" [",sub,"]");
|
|
190119
|
+
},
|
|
190120
|
+
exit: function (n, childCtx) {
|
|
190121
|
+
if (childCtx && childCtx.tag) {
|
|
190122
|
+
buf.push('</', childCtx.tag, '>');
|
|
189597
190123
|
}
|
|
189598
|
-
|
|
189599
|
-
|
|
189600
|
-
return;
|
|
189601
|
-
case PROCESSING_INSTRUCTION_NODE:
|
|
189602
|
-
return buf.push( "<?",node.target," ",node.data,"?>");
|
|
189603
|
-
case ENTITY_REFERENCE_NODE:
|
|
189604
|
-
return buf.push( '&',node.nodeName,';');
|
|
189605
|
-
//case ENTITY_NODE:
|
|
189606
|
-
//case NOTATION_NODE:
|
|
189607
|
-
default:
|
|
189608
|
-
buf.push('??',node.nodeName);
|
|
189609
|
-
}
|
|
190124
|
+
},
|
|
190125
|
+
});
|
|
189610
190126
|
}
|
|
189611
|
-
|
|
189612
|
-
|
|
189613
|
-
|
|
189614
|
-
|
|
189615
|
-
|
|
189616
|
-
|
|
189617
|
-
|
|
189618
|
-
|
|
189619
|
-
|
|
189620
|
-
|
|
189621
|
-
|
|
189622
|
-
|
|
189623
|
-
|
|
189624
|
-
|
|
189625
|
-
|
|
189626
|
-
|
|
189627
|
-
|
|
189628
|
-
|
|
189629
|
-
|
|
189630
|
-
|
|
189631
|
-
|
|
189632
|
-
|
|
189633
|
-
|
|
189634
|
-
|
|
189635
|
-
|
|
189636
|
-
|
|
189637
|
-
|
|
189638
|
-
|
|
189639
|
-
|
|
189640
|
-
|
|
189641
|
-
|
|
189642
|
-
|
|
189643
|
-
|
|
189644
|
-
|
|
189645
|
-
|
|
189646
|
-
|
|
189647
|
-
|
|
189648
|
-
var child = node.firstChild;
|
|
189649
|
-
while(child){
|
|
189650
|
-
node2.appendChild(importNode(doc,child,deep));
|
|
189651
|
-
child = child.nextSibling;
|
|
189652
|
-
}
|
|
189653
|
-
}
|
|
189654
|
-
return node2;
|
|
190127
|
+
/**
|
|
190128
|
+
* Imports a node from a different document into `doc`, creating a new copy.
|
|
190129
|
+
* Delegates to {@link walkDOM} for traversal. Each node in the subtree is shallow-cloned,
|
|
190130
|
+
* stamped with `doc` as its `ownerDocument`, and detached (`parentNode` set to `null`).
|
|
190131
|
+
* Children are imported recursively when `deep` is `true`; for {@link Attr} nodes `deep` is
|
|
190132
|
+
* always forced to `true`
|
|
190133
|
+
* because an attribute's value lives in a child text node.
|
|
190134
|
+
*
|
|
190135
|
+
* @param {Document} doc
|
|
190136
|
+
* The document that will own the imported node.
|
|
190137
|
+
* @param {Node} node
|
|
190138
|
+
* The node to import.
|
|
190139
|
+
* @param {boolean} deep
|
|
190140
|
+
* If `true`, descendants are imported recursively.
|
|
190141
|
+
* @returns {Node}
|
|
190142
|
+
* The newly imported node, now owned by `doc`.
|
|
190143
|
+
*/
|
|
190144
|
+
function importNode(doc, node, deep) {
|
|
190145
|
+
var destRoot;
|
|
190146
|
+
walkDOM(node, null, {
|
|
190147
|
+
enter: function (srcNode, destParent) {
|
|
190148
|
+
// Shallow-clone the node and stamp it into the target document.
|
|
190149
|
+
var destNode = srcNode.cloneNode(false);
|
|
190150
|
+
destNode.ownerDocument = doc;
|
|
190151
|
+
destNode.parentNode = null;
|
|
190152
|
+
// capture as the root of the imported subtree or attach to parent.
|
|
190153
|
+
if (destParent === null) {
|
|
190154
|
+
destRoot = destNode;
|
|
190155
|
+
} else {
|
|
190156
|
+
destParent.appendChild(destNode);
|
|
190157
|
+
}
|
|
190158
|
+
// ATTRIBUTE_NODE must always be imported deeply: its value lives in a child text node.
|
|
190159
|
+
var shouldDeep = srcNode.nodeType === ATTRIBUTE_NODE || deep;
|
|
190160
|
+
return shouldDeep ? destNode : null;
|
|
190161
|
+
},
|
|
190162
|
+
});
|
|
190163
|
+
return destRoot;
|
|
189655
190164
|
}
|
|
189656
190165
|
//
|
|
189657
190166
|
//var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1,
|
|
189658
190167
|
// attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
|
|
189659
|
-
function cloneNode(doc,node,deep){
|
|
189660
|
-
var
|
|
189661
|
-
|
|
189662
|
-
|
|
189663
|
-
|
|
189664
|
-
|
|
189665
|
-
|
|
189666
|
-
|
|
190168
|
+
function cloneNode(doc, node, deep) {
|
|
190169
|
+
var destRoot;
|
|
190170
|
+
walkDOM(node, null, {
|
|
190171
|
+
enter: function (srcNode, destParent) {
|
|
190172
|
+
// 1. Create a blank node of the same type and copy all scalar own properties.
|
|
190173
|
+
var destNode = new srcNode.constructor();
|
|
190174
|
+
for (var n in srcNode) {
|
|
190175
|
+
if (Object.prototype.hasOwnProperty.call(srcNode, n)) {
|
|
190176
|
+
var v = srcNode[n];
|
|
190177
|
+
if (typeof v != 'object') {
|
|
190178
|
+
if (v != destNode[n]) {
|
|
190179
|
+
destNode[n] = v;
|
|
190180
|
+
}
|
|
190181
|
+
}
|
|
189667
190182
|
}
|
|
189668
190183
|
}
|
|
189669
|
-
|
|
189670
|
-
|
|
189671
|
-
|
|
189672
|
-
|
|
189673
|
-
|
|
189674
|
-
|
|
189675
|
-
|
|
189676
|
-
|
|
189677
|
-
|
|
189678
|
-
|
|
189679
|
-
|
|
189680
|
-
|
|
189681
|
-
|
|
189682
|
-
|
|
189683
|
-
|
|
189684
|
-
|
|
189685
|
-
|
|
189686
|
-
|
|
189687
|
-
|
|
189688
|
-
|
|
189689
|
-
|
|
189690
|
-
|
|
189691
|
-
|
|
189692
|
-
|
|
189693
|
-
|
|
189694
|
-
|
|
190184
|
+
if (srcNode.childNodes) {
|
|
190185
|
+
destNode.childNodes = new NodeList();
|
|
190186
|
+
}
|
|
190187
|
+
destNode.ownerDocument = doc;
|
|
190188
|
+
// 2. Handle node-type-specific setup.
|
|
190189
|
+
// Attributes are not DOM children, so they are cloned inline here
|
|
190190
|
+
// rather than by walkDOM descent.
|
|
190191
|
+
// ATTRIBUTE_NODE forces deep=true so its own children are walked.
|
|
190192
|
+
var shouldDeep = deep;
|
|
190193
|
+
switch (destNode.nodeType) {
|
|
190194
|
+
case ELEMENT_NODE:
|
|
190195
|
+
var attrs = srcNode.attributes;
|
|
190196
|
+
var attrs2 = (destNode.attributes = new NamedNodeMap());
|
|
190197
|
+
var len = attrs.length;
|
|
190198
|
+
attrs2._ownerElement = destNode;
|
|
190199
|
+
for (var i = 0; i < len; i++) {
|
|
190200
|
+
destNode.setAttributeNode(cloneNode(doc, attrs.item(i), true));
|
|
190201
|
+
}
|
|
190202
|
+
break;
|
|
190203
|
+
case ATTRIBUTE_NODE:
|
|
190204
|
+
shouldDeep = true;
|
|
190205
|
+
}
|
|
190206
|
+
// 3. Attach to parent, or capture as the root of the cloned subtree.
|
|
190207
|
+
if (destParent !== null) {
|
|
190208
|
+
destParent.appendChild(destNode);
|
|
190209
|
+
} else {
|
|
190210
|
+
destRoot = destNode;
|
|
190211
|
+
}
|
|
190212
|
+
// 4. Return destNode as the context for children (causes walkDOM to descend),
|
|
190213
|
+
// or null to skip children (shallow clone).
|
|
190214
|
+
return shouldDeep ? destNode : null;
|
|
190215
|
+
},
|
|
190216
|
+
});
|
|
190217
|
+
return destRoot;
|
|
189695
190218
|
}
|
|
189696
190219
|
|
|
189697
190220
|
function __set__(object,key,value){
|
|
@@ -189707,49 +190230,55 @@ function requireDom () {
|
|
|
189707
190230
|
}
|
|
189708
190231
|
});
|
|
189709
190232
|
|
|
189710
|
-
|
|
189711
|
-
|
|
189712
|
-
|
|
190233
|
+
/**
|
|
190234
|
+
* The text content of this node and its descendants.
|
|
190235
|
+
*
|
|
190236
|
+
* Setting `textContent` on an element or document fragment replaces all child nodes with a
|
|
190237
|
+
* single text node; on other nodes it sets `data`, `value`, and `nodeValue` directly.
|
|
190238
|
+
*
|
|
190239
|
+
* @type {string | null}
|
|
190240
|
+
* @see {@link https://dom.spec.whatwg.org/#dom-node-textcontent}
|
|
190241
|
+
*/
|
|
190242
|
+
Object.defineProperty(Node.prototype, 'textContent', {
|
|
190243
|
+
get: function () {
|
|
190244
|
+
if (this.nodeType === ELEMENT_NODE || this.nodeType === DOCUMENT_FRAGMENT_NODE) {
|
|
190245
|
+
var buf = [];
|
|
190246
|
+
walkDOM(this, null, {
|
|
190247
|
+
enter: function (n) {
|
|
190248
|
+
if (n.nodeType === ELEMENT_NODE || n.nodeType === DOCUMENT_FRAGMENT_NODE) {
|
|
190249
|
+
return true; // enter children
|
|
190250
|
+
}
|
|
190251
|
+
if (n.nodeType === PROCESSING_INSTRUCTION_NODE || n.nodeType === COMMENT_NODE) {
|
|
190252
|
+
return null; // excluded from text content
|
|
190253
|
+
}
|
|
190254
|
+
buf.push(n.nodeValue);
|
|
190255
|
+
},
|
|
190256
|
+
});
|
|
190257
|
+
return buf.join('');
|
|
190258
|
+
}
|
|
190259
|
+
return this.nodeValue;
|
|
189713
190260
|
},
|
|
189714
190261
|
|
|
189715
|
-
set:function(data){
|
|
189716
|
-
switch(this.nodeType){
|
|
189717
|
-
|
|
189718
|
-
|
|
189719
|
-
|
|
189720
|
-
|
|
189721
|
-
|
|
189722
|
-
|
|
189723
|
-
|
|
189724
|
-
|
|
189725
|
-
|
|
190262
|
+
set: function (data) {
|
|
190263
|
+
switch (this.nodeType) {
|
|
190264
|
+
case ELEMENT_NODE:
|
|
190265
|
+
case DOCUMENT_FRAGMENT_NODE:
|
|
190266
|
+
while (this.firstChild) {
|
|
190267
|
+
this.removeChild(this.firstChild);
|
|
190268
|
+
}
|
|
190269
|
+
if (data || String(data)) {
|
|
190270
|
+
this.appendChild(this.ownerDocument.createTextNode(data));
|
|
190271
|
+
}
|
|
190272
|
+
break;
|
|
189726
190273
|
|
|
189727
|
-
|
|
189728
|
-
|
|
189729
|
-
|
|
189730
|
-
|
|
190274
|
+
default:
|
|
190275
|
+
this.data = data;
|
|
190276
|
+
this.value = data;
|
|
190277
|
+
this.nodeValue = data;
|
|
189731
190278
|
}
|
|
189732
|
-
}
|
|
190279
|
+
},
|
|
189733
190280
|
});
|
|
189734
190281
|
|
|
189735
|
-
function getTextContent(node){
|
|
189736
|
-
switch(node.nodeType){
|
|
189737
|
-
case ELEMENT_NODE:
|
|
189738
|
-
case DOCUMENT_FRAGMENT_NODE:
|
|
189739
|
-
var buf = [];
|
|
189740
|
-
node = node.firstChild;
|
|
189741
|
-
while(node){
|
|
189742
|
-
if(node.nodeType!==7 && node.nodeType !==8){
|
|
189743
|
-
buf.push(getTextContent(node));
|
|
189744
|
-
}
|
|
189745
|
-
node = node.nextSibling;
|
|
189746
|
-
}
|
|
189747
|
-
return buf.join('');
|
|
189748
|
-
default:
|
|
189749
|
-
return node.nodeValue;
|
|
189750
|
-
}
|
|
189751
|
-
}
|
|
189752
|
-
|
|
189753
190282
|
__set__ = function(object,key,value){
|
|
189754
190283
|
//console.log(value)
|
|
189755
190284
|
object['$$'+key] = value;
|
|
@@ -189765,6 +190294,7 @@ function requireDom () {
|
|
|
189765
190294
|
dom.Element = Element;
|
|
189766
190295
|
dom.Node = Node;
|
|
189767
190296
|
dom.NodeList = NodeList;
|
|
190297
|
+
dom.walkDOM = walkDOM;
|
|
189768
190298
|
dom.XMLSerializer = XMLSerializer;
|
|
189769
190299
|
//}
|
|
189770
190300
|
return dom;
|
|
@@ -192555,7 +193085,7 @@ function requireSax () {
|
|
|
192555
193085
|
function parseInstruction(source,start,domBuilder){
|
|
192556
193086
|
var end = source.indexOf('?>',start);
|
|
192557
193087
|
if(end){
|
|
192558
|
-
var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)
|
|
193088
|
+
var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)$/);
|
|
192559
193089
|
if(match){
|
|
192560
193090
|
match[0].length;
|
|
192561
193091
|
domBuilder.processingInstruction(match[1], match[2]) ;
|