@scalar/api-client 0.11.4 → 0.12.0

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.
@@ -0,0 +1,2494 @@
1
+ var dom$1 = {};
2
+ var conventions$2 = {};
3
+ function freeze(object, oc) {
4
+ if (oc === void 0) {
5
+ oc = Object;
6
+ }
7
+ return oc && typeof oc.freeze === "function" ? oc.freeze(object) : object;
8
+ }
9
+ function assign(target, source) {
10
+ if (target === null || typeof target !== "object") {
11
+ throw new TypeError("target is not an object");
12
+ }
13
+ for (var key in source) {
14
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
15
+ target[key] = source[key];
16
+ }
17
+ }
18
+ return target;
19
+ }
20
+ var MIME_TYPE = freeze({
21
+ /**
22
+ * `text/html`, the only mime type that triggers treating an XML document as HTML.
23
+ *
24
+ * @see DOMParser.SupportedType.isHTML
25
+ * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
26
+ * @see https://en.wikipedia.org/wiki/HTML Wikipedia
27
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
28
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring WHATWG HTML Spec
29
+ */
30
+ HTML: "text/html",
31
+ /**
32
+ * Helper method to check a mime type if it indicates an HTML document
33
+ *
34
+ * @param {string} [value]
35
+ * @returns {boolean}
36
+ *
37
+ * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
38
+ * @see https://en.wikipedia.org/wiki/HTML Wikipedia
39
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
40
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring */
41
+ isHTML: function(value) {
42
+ return value === MIME_TYPE.HTML;
43
+ },
44
+ /**
45
+ * `application/xml`, the standard mime type for XML documents.
46
+ *
47
+ * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType registration
48
+ * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303
49
+ * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
50
+ */
51
+ XML_APPLICATION: "application/xml",
52
+ /**
53
+ * `text/html`, an alias for `application/xml`.
54
+ *
55
+ * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303
56
+ * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration
57
+ * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
58
+ */
59
+ XML_TEXT: "text/xml",
60
+ /**
61
+ * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,
62
+ * but is parsed as an XML document.
63
+ *
64
+ * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType registration
65
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec
66
+ * @see https://en.wikipedia.org/wiki/XHTML Wikipedia
67
+ */
68
+ XML_XHTML_APPLICATION: "application/xhtml+xml",
69
+ /**
70
+ * `image/svg+xml`,
71
+ *
72
+ * @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration
73
+ * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1
74
+ * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia
75
+ */
76
+ XML_SVG_IMAGE: "image/svg+xml"
77
+ });
78
+ var NAMESPACE$3 = freeze({
79
+ /**
80
+ * The XHTML namespace.
81
+ *
82
+ * @see http://www.w3.org/1999/xhtml
83
+ */
84
+ HTML: "http://www.w3.org/1999/xhtml",
85
+ /**
86
+ * Checks if `uri` equals `NAMESPACE.HTML`.
87
+ *
88
+ * @param {string} [uri]
89
+ *
90
+ * @see NAMESPACE.HTML
91
+ */
92
+ isHTML: function(uri) {
93
+ return uri === NAMESPACE$3.HTML;
94
+ },
95
+ /**
96
+ * The SVG namespace.
97
+ *
98
+ * @see http://www.w3.org/2000/svg
99
+ */
100
+ SVG: "http://www.w3.org/2000/svg",
101
+ /**
102
+ * The `xml:` namespace.
103
+ *
104
+ * @see http://www.w3.org/XML/1998/namespace
105
+ */
106
+ XML: "http://www.w3.org/XML/1998/namespace",
107
+ /**
108
+ * The `xmlns:` namespace
109
+ *
110
+ * @see https://www.w3.org/2000/xmlns/
111
+ */
112
+ XMLNS: "http://www.w3.org/2000/xmlns/"
113
+ });
114
+ conventions$2.assign = assign;
115
+ conventions$2.freeze = freeze;
116
+ conventions$2.MIME_TYPE = MIME_TYPE;
117
+ conventions$2.NAMESPACE = NAMESPACE$3;
118
+ var conventions$1 = conventions$2;
119
+ var NAMESPACE$2 = conventions$1.NAMESPACE;
120
+ function notEmptyString(input) {
121
+ return input !== "";
122
+ }
123
+ function splitOnASCIIWhitespace(input) {
124
+ return input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : [];
125
+ }
126
+ function orderedSetReducer(current, element) {
127
+ if (!current.hasOwnProperty(element)) {
128
+ current[element] = true;
129
+ }
130
+ return current;
131
+ }
132
+ function toOrderedSet(input) {
133
+ if (!input)
134
+ return [];
135
+ var list = splitOnASCIIWhitespace(input);
136
+ return Object.keys(list.reduce(orderedSetReducer, {}));
137
+ }
138
+ function arrayIncludes(list) {
139
+ return function(element) {
140
+ return list && list.indexOf(element) !== -1;
141
+ };
142
+ }
143
+ function copy(src, dest) {
144
+ for (var p in src) {
145
+ if (Object.prototype.hasOwnProperty.call(src, p)) {
146
+ dest[p] = src[p];
147
+ }
148
+ }
149
+ }
150
+ function _extends(Class, Super) {
151
+ var pt = Class.prototype;
152
+ if (!(pt instanceof Super)) {
153
+ let t = function() {
154
+ };
155
+ t.prototype = Super.prototype;
156
+ t = new t();
157
+ copy(pt, t);
158
+ Class.prototype = pt = t;
159
+ }
160
+ if (pt.constructor != Class) {
161
+ if (typeof Class != "function") {
162
+ console.error("unknown Class:" + Class);
163
+ }
164
+ pt.constructor = Class;
165
+ }
166
+ }
167
+ var NodeType = {};
168
+ var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
169
+ var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
170
+ var TEXT_NODE = NodeType.TEXT_NODE = 3;
171
+ var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
172
+ var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
173
+ var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
174
+ var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
175
+ var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
176
+ var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;
177
+ var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
178
+ var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
179
+ var NOTATION_NODE = NodeType.NOTATION_NODE = 12;
180
+ var ExceptionCode = {};
181
+ var ExceptionMessage = {};
182
+ ExceptionCode.INDEX_SIZE_ERR = (ExceptionMessage[1] = "Index size error", 1);
183
+ ExceptionCode.DOMSTRING_SIZE_ERR = (ExceptionMessage[2] = "DOMString size error", 2);
184
+ var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = (ExceptionMessage[3] = "Hierarchy request error", 3);
185
+ ExceptionCode.WRONG_DOCUMENT_ERR = (ExceptionMessage[4] = "Wrong document", 4);
186
+ ExceptionCode.INVALID_CHARACTER_ERR = (ExceptionMessage[5] = "Invalid character", 5);
187
+ ExceptionCode.NO_DATA_ALLOWED_ERR = (ExceptionMessage[6] = "No data allowed", 6);
188
+ ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = (ExceptionMessage[7] = "No modification allowed", 7);
189
+ var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = (ExceptionMessage[8] = "Not found", 8);
190
+ ExceptionCode.NOT_SUPPORTED_ERR = (ExceptionMessage[9] = "Not supported", 9);
191
+ var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = (ExceptionMessage[10] = "Attribute in use", 10);
192
+ ExceptionCode.INVALID_STATE_ERR = (ExceptionMessage[11] = "Invalid state", 11);
193
+ ExceptionCode.SYNTAX_ERR = (ExceptionMessage[12] = "Syntax error", 12);
194
+ ExceptionCode.INVALID_MODIFICATION_ERR = (ExceptionMessage[13] = "Invalid modification", 13);
195
+ ExceptionCode.NAMESPACE_ERR = (ExceptionMessage[14] = "Invalid namespace", 14);
196
+ ExceptionCode.INVALID_ACCESS_ERR = (ExceptionMessage[15] = "Invalid access", 15);
197
+ function DOMException(code, message) {
198
+ if (message instanceof Error) {
199
+ var error = message;
200
+ } else {
201
+ error = this;
202
+ Error.call(this, ExceptionMessage[code]);
203
+ this.message = ExceptionMessage[code];
204
+ if (Error.captureStackTrace)
205
+ Error.captureStackTrace(this, DOMException);
206
+ }
207
+ error.code = code;
208
+ if (message)
209
+ this.message = this.message + ": " + message;
210
+ return error;
211
+ }
212
+ DOMException.prototype = Error.prototype;
213
+ copy(ExceptionCode, DOMException);
214
+ function NodeList() {
215
+ }
216
+ NodeList.prototype = {
217
+ /**
218
+ * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.
219
+ * @standard level1
220
+ */
221
+ length: 0,
222
+ /**
223
+ * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
224
+ * @standard level1
225
+ * @param index unsigned long
226
+ * Index into the collection.
227
+ * @return Node
228
+ * The node at the indexth position in the NodeList, or null if that is not a valid index.
229
+ */
230
+ item: function(index2) {
231
+ return this[index2] || null;
232
+ },
233
+ toString: function(isHTML, nodeFilter) {
234
+ for (var buf = [], i = 0; i < this.length; i++) {
235
+ serializeToString(this[i], buf, isHTML, nodeFilter);
236
+ }
237
+ return buf.join("");
238
+ },
239
+ /**
240
+ * @private
241
+ * @param {function (Node):boolean} predicate
242
+ * @returns {Node | undefined}
243
+ */
244
+ find: function(predicate) {
245
+ return Array.prototype.find.call(this, predicate);
246
+ },
247
+ /**
248
+ * @private
249
+ * @param {function (Node):boolean} predicate
250
+ * @returns {Node[]}
251
+ */
252
+ filter: function(predicate) {
253
+ return Array.prototype.filter.call(this, predicate);
254
+ },
255
+ /**
256
+ * @private
257
+ * @param {Node} item
258
+ * @returns {number}
259
+ */
260
+ indexOf: function(item) {
261
+ return Array.prototype.indexOf.call(this, item);
262
+ }
263
+ };
264
+ function LiveNodeList(node, refresh) {
265
+ this._node = node;
266
+ this._refresh = refresh;
267
+ _updateLiveList(this);
268
+ }
269
+ function _updateLiveList(list) {
270
+ var inc = list._node._inc || list._node.ownerDocument._inc;
271
+ if (list._inc != inc) {
272
+ var ls = list._refresh(list._node);
273
+ __set__(list, "length", ls.length);
274
+ copy(ls, list);
275
+ list._inc = inc;
276
+ }
277
+ }
278
+ LiveNodeList.prototype.item = function(i) {
279
+ _updateLiveList(this);
280
+ return this[i];
281
+ };
282
+ _extends(LiveNodeList, NodeList);
283
+ function NamedNodeMap() {
284
+ }
285
+ function _findNodeIndex(list, node) {
286
+ var i = list.length;
287
+ while (i--) {
288
+ if (list[i] === node) {
289
+ return i;
290
+ }
291
+ }
292
+ }
293
+ function _addNamedNode(el, list, newAttr, oldAttr) {
294
+ if (oldAttr) {
295
+ list[_findNodeIndex(list, oldAttr)] = newAttr;
296
+ } else {
297
+ list[list.length++] = newAttr;
298
+ }
299
+ if (el) {
300
+ newAttr.ownerElement = el;
301
+ var doc = el.ownerDocument;
302
+ if (doc) {
303
+ oldAttr && _onRemoveAttribute(doc, el, oldAttr);
304
+ _onAddAttribute(doc, el, newAttr);
305
+ }
306
+ }
307
+ }
308
+ function _removeNamedNode(el, list, attr) {
309
+ var i = _findNodeIndex(list, attr);
310
+ if (i >= 0) {
311
+ var lastIndex = list.length - 1;
312
+ while (i < lastIndex) {
313
+ list[i] = list[++i];
314
+ }
315
+ list.length = lastIndex;
316
+ if (el) {
317
+ var doc = el.ownerDocument;
318
+ if (doc) {
319
+ _onRemoveAttribute(doc, el, attr);
320
+ attr.ownerElement = null;
321
+ }
322
+ }
323
+ } else {
324
+ throw new DOMException(NOT_FOUND_ERR, new Error(el.tagName + "@" + attr));
325
+ }
326
+ }
327
+ NamedNodeMap.prototype = {
328
+ length: 0,
329
+ item: NodeList.prototype.item,
330
+ getNamedItem: function(key) {
331
+ var i = this.length;
332
+ while (i--) {
333
+ var attr = this[i];
334
+ if (attr.nodeName == key) {
335
+ return attr;
336
+ }
337
+ }
338
+ },
339
+ setNamedItem: function(attr) {
340
+ var el = attr.ownerElement;
341
+ if (el && el != this._ownerElement) {
342
+ throw new DOMException(INUSE_ATTRIBUTE_ERR);
343
+ }
344
+ var oldAttr = this.getNamedItem(attr.nodeName);
345
+ _addNamedNode(this._ownerElement, this, attr, oldAttr);
346
+ return oldAttr;
347
+ },
348
+ /* returns Node */
349
+ setNamedItemNS: function(attr) {
350
+ var el = attr.ownerElement, oldAttr;
351
+ if (el && el != this._ownerElement) {
352
+ throw new DOMException(INUSE_ATTRIBUTE_ERR);
353
+ }
354
+ oldAttr = this.getNamedItemNS(attr.namespaceURI, attr.localName);
355
+ _addNamedNode(this._ownerElement, this, attr, oldAttr);
356
+ return oldAttr;
357
+ },
358
+ /* returns Node */
359
+ removeNamedItem: function(key) {
360
+ var attr = this.getNamedItem(key);
361
+ _removeNamedNode(this._ownerElement, this, attr);
362
+ return attr;
363
+ },
364
+ // raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
365
+ //for level2
366
+ removeNamedItemNS: function(namespaceURI, localName) {
367
+ var attr = this.getNamedItemNS(namespaceURI, localName);
368
+ _removeNamedNode(this._ownerElement, this, attr);
369
+ return attr;
370
+ },
371
+ getNamedItemNS: function(namespaceURI, localName) {
372
+ var i = this.length;
373
+ while (i--) {
374
+ var node = this[i];
375
+ if (node.localName == localName && node.namespaceURI == namespaceURI) {
376
+ return node;
377
+ }
378
+ }
379
+ return null;
380
+ }
381
+ };
382
+ function DOMImplementation$1() {
383
+ }
384
+ DOMImplementation$1.prototype = {
385
+ /**
386
+ * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given feature is supported.
387
+ * The different implementations fairly diverged in what kind of features were reported.
388
+ * The latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use.
389
+ *
390
+ * @deprecated It is deprecated and modern browsers return true in all cases.
391
+ *
392
+ * @param {string} feature
393
+ * @param {string} [version]
394
+ * @returns {boolean} always true
395
+ *
396
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN
397
+ * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core
398
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard
399
+ */
400
+ hasFeature: function(feature, version) {
401
+ return true;
402
+ },
403
+ /**
404
+ * Creates an XML Document object of the specified type with its document element.
405
+ *
406
+ * __It behaves slightly different from the description in the living standard__:
407
+ * - There is no interface/class `XMLDocument`, it returns a `Document` instance.
408
+ * - `contentType`, `encoding`, `mode`, `origin`, `url` fields are currently not declared.
409
+ * - this implementation is not validating names or qualified names
410
+ * (when parsing XML strings, the SAX parser takes care of that)
411
+ *
412
+ * @param {string|null} namespaceURI
413
+ * @param {string} qualifiedName
414
+ * @param {DocumentType=null} doctype
415
+ * @returns {Document}
416
+ *
417
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN
418
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM Level 2 Core (initial)
419
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core
420
+ *
421
+ * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
422
+ * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
423
+ * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
424
+ */
425
+ createDocument: function(namespaceURI, qualifiedName, doctype) {
426
+ var doc = new Document();
427
+ doc.implementation = this;
428
+ doc.childNodes = new NodeList();
429
+ doc.doctype = doctype || null;
430
+ if (doctype) {
431
+ doc.appendChild(doctype);
432
+ }
433
+ if (qualifiedName) {
434
+ var root = doc.createElementNS(namespaceURI, qualifiedName);
435
+ doc.appendChild(root);
436
+ }
437
+ return doc;
438
+ },
439
+ /**
440
+ * Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.
441
+ *
442
+ * __This behavior is slightly different from the in the specs__:
443
+ * - this implementation is not validating names or qualified names
444
+ * (when parsing XML strings, the SAX parser takes care of that)
445
+ *
446
+ * @param {string} qualifiedName
447
+ * @param {string} [publicId]
448
+ * @param {string} [systemId]
449
+ * @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation
450
+ * or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`
451
+ *
452
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType MDN
453
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM Level 2 Core
454
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living Standard
455
+ *
456
+ * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
457
+ * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
458
+ * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
459
+ */
460
+ createDocumentType: function(qualifiedName, publicId, systemId) {
461
+ var node = new DocumentType();
462
+ node.name = qualifiedName;
463
+ node.nodeName = qualifiedName;
464
+ node.publicId = publicId || "";
465
+ node.systemId = systemId || "";
466
+ return node;
467
+ }
468
+ };
469
+ function Node() {
470
+ }
471
+ Node.prototype = {
472
+ firstChild: null,
473
+ lastChild: null,
474
+ previousSibling: null,
475
+ nextSibling: null,
476
+ attributes: null,
477
+ parentNode: null,
478
+ childNodes: null,
479
+ ownerDocument: null,
480
+ nodeValue: null,
481
+ namespaceURI: null,
482
+ prefix: null,
483
+ localName: null,
484
+ // Modified in DOM Level 2:
485
+ insertBefore: function(newChild, refChild) {
486
+ return _insertBefore(this, newChild, refChild);
487
+ },
488
+ replaceChild: function(newChild, oldChild) {
489
+ this.insertBefore(newChild, oldChild);
490
+ if (oldChild) {
491
+ this.removeChild(oldChild);
492
+ }
493
+ },
494
+ removeChild: function(oldChild) {
495
+ return _removeChild(this, oldChild);
496
+ },
497
+ appendChild: function(newChild) {
498
+ return this.insertBefore(newChild, null);
499
+ },
500
+ hasChildNodes: function() {
501
+ return this.firstChild != null;
502
+ },
503
+ cloneNode: function(deep) {
504
+ return cloneNode(this.ownerDocument || this, this, deep);
505
+ },
506
+ // Modified in DOM Level 2:
507
+ normalize: function() {
508
+ var child = this.firstChild;
509
+ while (child) {
510
+ var next = child.nextSibling;
511
+ if (next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE) {
512
+ this.removeChild(next);
513
+ child.appendData(next.data);
514
+ } else {
515
+ child.normalize();
516
+ child = next;
517
+ }
518
+ }
519
+ },
520
+ // Introduced in DOM Level 2:
521
+ isSupported: function(feature, version) {
522
+ return this.ownerDocument.implementation.hasFeature(feature, version);
523
+ },
524
+ // Introduced in DOM Level 2:
525
+ hasAttributes: function() {
526
+ return this.attributes.length > 0;
527
+ },
528
+ /**
529
+ * Look up the prefix associated to the given namespace URI, starting from this node.
530
+ * **The default namespace declarations are ignored by this method.**
531
+ * See Namespace Prefix Lookup for details on the algorithm used by this method.
532
+ *
533
+ * _Note: The implementation seems to be incomplete when compared to the algorithm described in the specs._
534
+ *
535
+ * @param {string | null} namespaceURI
536
+ * @returns {string | null}
537
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix
538
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo
539
+ * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix
540
+ * @see https://github.com/xmldom/xmldom/issues/322
541
+ */
542
+ lookupPrefix: function(namespaceURI) {
543
+ var el = this;
544
+ while (el) {
545
+ var map = el._nsMap;
546
+ if (map) {
547
+ for (var n in map) {
548
+ if (Object.prototype.hasOwnProperty.call(map, n) && map[n] === namespaceURI) {
549
+ return n;
550
+ }
551
+ }
552
+ }
553
+ el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
554
+ }
555
+ return null;
556
+ },
557
+ // Introduced in DOM Level 3:
558
+ lookupNamespaceURI: function(prefix) {
559
+ var el = this;
560
+ while (el) {
561
+ var map = el._nsMap;
562
+ if (map) {
563
+ if (Object.prototype.hasOwnProperty.call(map, prefix)) {
564
+ return map[prefix];
565
+ }
566
+ }
567
+ el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
568
+ }
569
+ return null;
570
+ },
571
+ // Introduced in DOM Level 3:
572
+ isDefaultNamespace: function(namespaceURI) {
573
+ var prefix = this.lookupPrefix(namespaceURI);
574
+ return prefix == null;
575
+ }
576
+ };
577
+ function _xmlEncoder(c) {
578
+ return c == "<" && "&lt;" || c == ">" && "&gt;" || c == "&" && "&amp;" || c == '"' && "&quot;" || "&#" + c.charCodeAt() + ";";
579
+ }
580
+ copy(NodeType, Node);
581
+ copy(NodeType, Node.prototype);
582
+ function _visitNode(node, callback) {
583
+ if (callback(node)) {
584
+ return true;
585
+ }
586
+ if (node = node.firstChild) {
587
+ do {
588
+ if (_visitNode(node, callback)) {
589
+ return true;
590
+ }
591
+ } while (node = node.nextSibling);
592
+ }
593
+ }
594
+ function Document() {
595
+ }
596
+ function _onAddAttribute(doc, el, newAttr) {
597
+ doc && doc._inc++;
598
+ var ns = newAttr.namespaceURI;
599
+ if (ns === NAMESPACE$2.XMLNS) {
600
+ el._nsMap[newAttr.prefix ? newAttr.localName : ""] = newAttr.value;
601
+ }
602
+ }
603
+ function _onRemoveAttribute(doc, el, newAttr, remove) {
604
+ doc && doc._inc++;
605
+ var ns = newAttr.namespaceURI;
606
+ if (ns === NAMESPACE$2.XMLNS) {
607
+ delete el._nsMap[newAttr.prefix ? newAttr.localName : ""];
608
+ }
609
+ }
610
+ function _onUpdateChild(doc, el, newChild) {
611
+ if (doc && doc._inc) {
612
+ doc._inc++;
613
+ var cs = el.childNodes;
614
+ if (newChild) {
615
+ cs[cs.length++] = newChild;
616
+ } else {
617
+ var child = el.firstChild;
618
+ var i = 0;
619
+ while (child) {
620
+ cs[i++] = child;
621
+ child = child.nextSibling;
622
+ }
623
+ cs.length = i;
624
+ delete cs[cs.length];
625
+ }
626
+ }
627
+ }
628
+ function _removeChild(parentNode, child) {
629
+ var previous = child.previousSibling;
630
+ var next = child.nextSibling;
631
+ if (previous) {
632
+ previous.nextSibling = next;
633
+ } else {
634
+ parentNode.firstChild = next;
635
+ }
636
+ if (next) {
637
+ next.previousSibling = previous;
638
+ } else {
639
+ parentNode.lastChild = previous;
640
+ }
641
+ child.parentNode = null;
642
+ child.previousSibling = null;
643
+ child.nextSibling = null;
644
+ _onUpdateChild(parentNode.ownerDocument, parentNode);
645
+ return child;
646
+ }
647
+ function hasValidParentNodeType(node) {
648
+ return node && (node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.ELEMENT_NODE);
649
+ }
650
+ function hasInsertableNodeType(node) {
651
+ return node && (isElementNode(node) || isTextNode(node) || isDocTypeNode(node) || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.COMMENT_NODE || node.nodeType === Node.PROCESSING_INSTRUCTION_NODE);
652
+ }
653
+ function isDocTypeNode(node) {
654
+ return node && node.nodeType === Node.DOCUMENT_TYPE_NODE;
655
+ }
656
+ function isElementNode(node) {
657
+ return node && node.nodeType === Node.ELEMENT_NODE;
658
+ }
659
+ function isTextNode(node) {
660
+ return node && node.nodeType === Node.TEXT_NODE;
661
+ }
662
+ function isElementInsertionPossible(doc, child) {
663
+ var parentChildNodes = doc.childNodes || [];
664
+ if (parentChildNodes.find(isElementNode) || isDocTypeNode(child)) {
665
+ return false;
666
+ }
667
+ var docTypeNode = parentChildNodes.find(isDocTypeNode);
668
+ return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
669
+ }
670
+ function _insertBefore(parent, node, child) {
671
+ if (!hasValidParentNodeType(parent)) {
672
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Unexpected parent node type " + parent.nodeType);
673
+ }
674
+ if (child && child.parentNode !== parent) {
675
+ throw new DOMException(NOT_FOUND_ERR, "child not in parent");
676
+ }
677
+ if (!hasInsertableNodeType(node) || // the sax parser currently adds top level text nodes, this will be fixed in 0.9.0
678
+ // || (node.nodeType === Node.TEXT_NODE && parent.nodeType === Node.DOCUMENT_NODE)
679
+ isDocTypeNode(node) && parent.nodeType !== Node.DOCUMENT_NODE) {
680
+ throw new DOMException(
681
+ HIERARCHY_REQUEST_ERR,
682
+ "Unexpected node type " + node.nodeType + " for parent node type " + parent.nodeType
683
+ );
684
+ }
685
+ var parentChildNodes = parent.childNodes || [];
686
+ var nodeChildNodes = node.childNodes || [];
687
+ if (parent.nodeType === Node.DOCUMENT_NODE) {
688
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
689
+ let nodeChildElements = nodeChildNodes.filter(isElementNode);
690
+ if (nodeChildElements.length > 1 || nodeChildNodes.find(isTextNode)) {
691
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "More than one element or text in fragment");
692
+ }
693
+ if (nodeChildElements.length === 1 && !isElementInsertionPossible(parent, child)) {
694
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Element in fragment can not be inserted before doctype");
695
+ }
696
+ }
697
+ if (isElementNode(node)) {
698
+ if (parentChildNodes.find(isElementNode) || !isElementInsertionPossible(parent, child)) {
699
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Only one element can be added and only after doctype");
700
+ }
701
+ }
702
+ if (isDocTypeNode(node)) {
703
+ if (parentChildNodes.find(isDocTypeNode)) {
704
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Only one doctype is allowed");
705
+ }
706
+ let parentElementChild = parentChildNodes.find(isElementNode);
707
+ if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
708
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Doctype can only be inserted before an element");
709
+ }
710
+ if (!child && parentElementChild) {
711
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Doctype can not be appended since element is present");
712
+ }
713
+ }
714
+ }
715
+ var cp = node.parentNode;
716
+ if (cp) {
717
+ cp.removeChild(node);
718
+ }
719
+ if (node.nodeType === DOCUMENT_FRAGMENT_NODE) {
720
+ var newFirst = node.firstChild;
721
+ if (newFirst == null) {
722
+ return node;
723
+ }
724
+ var newLast = node.lastChild;
725
+ } else {
726
+ newFirst = newLast = node;
727
+ }
728
+ var pre = child ? child.previousSibling : parent.lastChild;
729
+ newFirst.previousSibling = pre;
730
+ newLast.nextSibling = child;
731
+ if (pre) {
732
+ pre.nextSibling = newFirst;
733
+ } else {
734
+ parent.firstChild = newFirst;
735
+ }
736
+ if (child == null) {
737
+ parent.lastChild = newLast;
738
+ } else {
739
+ child.previousSibling = newLast;
740
+ }
741
+ do {
742
+ newFirst.parentNode = parent;
743
+ } while (newFirst !== newLast && (newFirst = newFirst.nextSibling));
744
+ _onUpdateChild(parent.ownerDocument || parent, parent);
745
+ if (node.nodeType == DOCUMENT_FRAGMENT_NODE) {
746
+ node.firstChild = node.lastChild = null;
747
+ }
748
+ return node;
749
+ }
750
+ function _appendSingleChild(parentNode, newChild) {
751
+ if (newChild.parentNode) {
752
+ newChild.parentNode.removeChild(newChild);
753
+ }
754
+ newChild.parentNode = parentNode;
755
+ newChild.previousSibling = parentNode.lastChild;
756
+ newChild.nextSibling = null;
757
+ if (newChild.previousSibling) {
758
+ newChild.previousSibling.nextSibling = newChild;
759
+ } else {
760
+ parentNode.firstChild = newChild;
761
+ }
762
+ parentNode.lastChild = newChild;
763
+ _onUpdateChild(parentNode.ownerDocument, parentNode, newChild);
764
+ return newChild;
765
+ }
766
+ Document.prototype = {
767
+ //implementation : null,
768
+ nodeName: "#document",
769
+ nodeType: DOCUMENT_NODE,
770
+ /**
771
+ * The DocumentType node of the document.
772
+ *
773
+ * @readonly
774
+ * @type DocumentType
775
+ */
776
+ doctype: null,
777
+ documentElement: null,
778
+ _inc: 1,
779
+ insertBefore: function(newChild, refChild) {
780
+ if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
781
+ var child = newChild.firstChild;
782
+ while (child) {
783
+ var next = child.nextSibling;
784
+ this.insertBefore(child, refChild);
785
+ child = next;
786
+ }
787
+ return newChild;
788
+ }
789
+ _insertBefore(this, newChild, refChild);
790
+ newChild.ownerDocument = this;
791
+ if (this.documentElement === null && newChild.nodeType === ELEMENT_NODE) {
792
+ this.documentElement = newChild;
793
+ }
794
+ return newChild;
795
+ },
796
+ removeChild: function(oldChild) {
797
+ if (this.documentElement == oldChild) {
798
+ this.documentElement = null;
799
+ }
800
+ return _removeChild(this, oldChild);
801
+ },
802
+ // Introduced in DOM Level 2:
803
+ importNode: function(importedNode, deep) {
804
+ return importNode(this, importedNode, deep);
805
+ },
806
+ // Introduced in DOM Level 2:
807
+ getElementById: function(id) {
808
+ var rtv = null;
809
+ _visitNode(this.documentElement, function(node) {
810
+ if (node.nodeType == ELEMENT_NODE) {
811
+ if (node.getAttribute("id") == id) {
812
+ rtv = node;
813
+ return true;
814
+ }
815
+ }
816
+ });
817
+ return rtv;
818
+ },
819
+ /**
820
+ * The `getElementsByClassName` method of `Document` interface returns an array-like object
821
+ * of all child elements which have **all** of the given class name(s).
822
+ *
823
+ * Returns an empty list if `classeNames` is an empty string or only contains HTML white space characters.
824
+ *
825
+ *
826
+ * Warning: This is a live LiveNodeList.
827
+ * Changes in the DOM will reflect in the array as the changes occur.
828
+ * If an element selected by this array no longer qualifies for the selector,
829
+ * it will automatically be removed. Be aware of this for iteration purposes.
830
+ *
831
+ * @param {string} classNames is a string representing the class name(s) to match; multiple class names are separated by (ASCII-)whitespace
832
+ *
833
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
834
+ * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
835
+ */
836
+ getElementsByClassName: function(classNames) {
837
+ var classNamesSet = toOrderedSet(classNames);
838
+ return new LiveNodeList(this, function(base) {
839
+ var ls = [];
840
+ if (classNamesSet.length > 0) {
841
+ _visitNode(base.documentElement, function(node) {
842
+ if (node !== base && node.nodeType === ELEMENT_NODE) {
843
+ var nodeClassNames = node.getAttribute("class");
844
+ if (nodeClassNames) {
845
+ var matches = classNames === nodeClassNames;
846
+ if (!matches) {
847
+ var nodeClassNamesSet = toOrderedSet(nodeClassNames);
848
+ matches = classNamesSet.every(arrayIncludes(nodeClassNamesSet));
849
+ }
850
+ if (matches) {
851
+ ls.push(node);
852
+ }
853
+ }
854
+ }
855
+ });
856
+ }
857
+ return ls;
858
+ });
859
+ },
860
+ //document factory method:
861
+ createElement: function(tagName) {
862
+ var node = new Element();
863
+ node.ownerDocument = this;
864
+ node.nodeName = tagName;
865
+ node.tagName = tagName;
866
+ node.localName = tagName;
867
+ node.childNodes = new NodeList();
868
+ var attrs = node.attributes = new NamedNodeMap();
869
+ attrs._ownerElement = node;
870
+ return node;
871
+ },
872
+ createDocumentFragment: function() {
873
+ var node = new DocumentFragment();
874
+ node.ownerDocument = this;
875
+ node.childNodes = new NodeList();
876
+ return node;
877
+ },
878
+ createTextNode: function(data) {
879
+ var node = new Text();
880
+ node.ownerDocument = this;
881
+ node.appendData(data);
882
+ return node;
883
+ },
884
+ createComment: function(data) {
885
+ var node = new Comment();
886
+ node.ownerDocument = this;
887
+ node.appendData(data);
888
+ return node;
889
+ },
890
+ createCDATASection: function(data) {
891
+ var node = new CDATASection();
892
+ node.ownerDocument = this;
893
+ node.appendData(data);
894
+ return node;
895
+ },
896
+ createProcessingInstruction: function(target, data) {
897
+ var node = new ProcessingInstruction();
898
+ node.ownerDocument = this;
899
+ node.tagName = node.target = target;
900
+ node.nodeValue = node.data = data;
901
+ return node;
902
+ },
903
+ createAttribute: function(name) {
904
+ var node = new Attr();
905
+ node.ownerDocument = this;
906
+ node.name = name;
907
+ node.nodeName = name;
908
+ node.localName = name;
909
+ node.specified = true;
910
+ return node;
911
+ },
912
+ createEntityReference: function(name) {
913
+ var node = new EntityReference();
914
+ node.ownerDocument = this;
915
+ node.nodeName = name;
916
+ return node;
917
+ },
918
+ // Introduced in DOM Level 2:
919
+ createElementNS: function(namespaceURI, qualifiedName) {
920
+ var node = new Element();
921
+ var pl = qualifiedName.split(":");
922
+ var attrs = node.attributes = new NamedNodeMap();
923
+ node.childNodes = new NodeList();
924
+ node.ownerDocument = this;
925
+ node.nodeName = qualifiedName;
926
+ node.tagName = qualifiedName;
927
+ node.namespaceURI = namespaceURI;
928
+ if (pl.length == 2) {
929
+ node.prefix = pl[0];
930
+ node.localName = pl[1];
931
+ } else {
932
+ node.localName = qualifiedName;
933
+ }
934
+ attrs._ownerElement = node;
935
+ return node;
936
+ },
937
+ // Introduced in DOM Level 2:
938
+ createAttributeNS: function(namespaceURI, qualifiedName) {
939
+ var node = new Attr();
940
+ var pl = qualifiedName.split(":");
941
+ node.ownerDocument = this;
942
+ node.nodeName = qualifiedName;
943
+ node.name = qualifiedName;
944
+ node.namespaceURI = namespaceURI;
945
+ node.specified = true;
946
+ if (pl.length == 2) {
947
+ node.prefix = pl[0];
948
+ node.localName = pl[1];
949
+ } else {
950
+ node.localName = qualifiedName;
951
+ }
952
+ return node;
953
+ }
954
+ };
955
+ _extends(Document, Node);
956
+ function Element() {
957
+ this._nsMap = {};
958
+ }
959
+ Element.prototype = {
960
+ nodeType: ELEMENT_NODE,
961
+ hasAttribute: function(name) {
962
+ return this.getAttributeNode(name) != null;
963
+ },
964
+ getAttribute: function(name) {
965
+ var attr = this.getAttributeNode(name);
966
+ return attr && attr.value || "";
967
+ },
968
+ getAttributeNode: function(name) {
969
+ return this.attributes.getNamedItem(name);
970
+ },
971
+ setAttribute: function(name, value) {
972
+ var attr = this.ownerDocument.createAttribute(name);
973
+ attr.value = attr.nodeValue = "" + value;
974
+ this.setAttributeNode(attr);
975
+ },
976
+ removeAttribute: function(name) {
977
+ var attr = this.getAttributeNode(name);
978
+ attr && this.removeAttributeNode(attr);
979
+ },
980
+ //four real opeartion method
981
+ appendChild: function(newChild) {
982
+ if (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) {
983
+ return this.insertBefore(newChild, null);
984
+ } else {
985
+ return _appendSingleChild(this, newChild);
986
+ }
987
+ },
988
+ setAttributeNode: function(newAttr) {
989
+ return this.attributes.setNamedItem(newAttr);
990
+ },
991
+ setAttributeNodeNS: function(newAttr) {
992
+ return this.attributes.setNamedItemNS(newAttr);
993
+ },
994
+ removeAttributeNode: function(oldAttr) {
995
+ return this.attributes.removeNamedItem(oldAttr.nodeName);
996
+ },
997
+ //get real attribute name,and remove it by removeAttributeNode
998
+ removeAttributeNS: function(namespaceURI, localName) {
999
+ var old = this.getAttributeNodeNS(namespaceURI, localName);
1000
+ old && this.removeAttributeNode(old);
1001
+ },
1002
+ hasAttributeNS: function(namespaceURI, localName) {
1003
+ return this.getAttributeNodeNS(namespaceURI, localName) != null;
1004
+ },
1005
+ getAttributeNS: function(namespaceURI, localName) {
1006
+ var attr = this.getAttributeNodeNS(namespaceURI, localName);
1007
+ return attr && attr.value || "";
1008
+ },
1009
+ setAttributeNS: function(namespaceURI, qualifiedName, value) {
1010
+ var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
1011
+ attr.value = attr.nodeValue = "" + value;
1012
+ this.setAttributeNode(attr);
1013
+ },
1014
+ getAttributeNodeNS: function(namespaceURI, localName) {
1015
+ return this.attributes.getNamedItemNS(namespaceURI, localName);
1016
+ },
1017
+ getElementsByTagName: function(tagName) {
1018
+ return new LiveNodeList(this, function(base) {
1019
+ var ls = [];
1020
+ _visitNode(base, function(node) {
1021
+ if (node !== base && node.nodeType == ELEMENT_NODE && (tagName === "*" || node.tagName == tagName)) {
1022
+ ls.push(node);
1023
+ }
1024
+ });
1025
+ return ls;
1026
+ });
1027
+ },
1028
+ getElementsByTagNameNS: function(namespaceURI, localName) {
1029
+ return new LiveNodeList(this, function(base) {
1030
+ var ls = [];
1031
+ _visitNode(base, function(node) {
1032
+ if (node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === "*" || node.namespaceURI === namespaceURI) && (localName === "*" || node.localName == localName)) {
1033
+ ls.push(node);
1034
+ }
1035
+ });
1036
+ return ls;
1037
+ });
1038
+ }
1039
+ };
1040
+ Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
1041
+ Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
1042
+ _extends(Element, Node);
1043
+ function Attr() {
1044
+ }
1045
+ Attr.prototype.nodeType = ATTRIBUTE_NODE;
1046
+ _extends(Attr, Node);
1047
+ function CharacterData() {
1048
+ }
1049
+ CharacterData.prototype = {
1050
+ data: "",
1051
+ substringData: function(offset, count) {
1052
+ return this.data.substring(offset, offset + count);
1053
+ },
1054
+ appendData: function(text) {
1055
+ text = this.data + text;
1056
+ this.nodeValue = this.data = text;
1057
+ this.length = text.length;
1058
+ },
1059
+ insertData: function(offset, text) {
1060
+ this.replaceData(offset, 0, text);
1061
+ },
1062
+ appendChild: function(newChild) {
1063
+ throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR]);
1064
+ },
1065
+ deleteData: function(offset, count) {
1066
+ this.replaceData(offset, count, "");
1067
+ },
1068
+ replaceData: function(offset, count, text) {
1069
+ var start = this.data.substring(0, offset);
1070
+ var end = this.data.substring(offset + count);
1071
+ text = start + text + end;
1072
+ this.nodeValue = this.data = text;
1073
+ this.length = text.length;
1074
+ }
1075
+ };
1076
+ _extends(CharacterData, Node);
1077
+ function Text() {
1078
+ }
1079
+ Text.prototype = {
1080
+ nodeName: "#text",
1081
+ nodeType: TEXT_NODE,
1082
+ splitText: function(offset) {
1083
+ var text = this.data;
1084
+ var newText = text.substring(offset);
1085
+ text = text.substring(0, offset);
1086
+ this.data = this.nodeValue = text;
1087
+ this.length = text.length;
1088
+ var newNode = this.ownerDocument.createTextNode(newText);
1089
+ if (this.parentNode) {
1090
+ this.parentNode.insertBefore(newNode, this.nextSibling);
1091
+ }
1092
+ return newNode;
1093
+ }
1094
+ };
1095
+ _extends(Text, CharacterData);
1096
+ function Comment() {
1097
+ }
1098
+ Comment.prototype = {
1099
+ nodeName: "#comment",
1100
+ nodeType: COMMENT_NODE
1101
+ };
1102
+ _extends(Comment, CharacterData);
1103
+ function CDATASection() {
1104
+ }
1105
+ CDATASection.prototype = {
1106
+ nodeName: "#cdata-section",
1107
+ nodeType: CDATA_SECTION_NODE
1108
+ };
1109
+ _extends(CDATASection, CharacterData);
1110
+ function DocumentType() {
1111
+ }
1112
+ DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
1113
+ _extends(DocumentType, Node);
1114
+ function Notation() {
1115
+ }
1116
+ Notation.prototype.nodeType = NOTATION_NODE;
1117
+ _extends(Notation, Node);
1118
+ function Entity() {
1119
+ }
1120
+ Entity.prototype.nodeType = ENTITY_NODE;
1121
+ _extends(Entity, Node);
1122
+ function EntityReference() {
1123
+ }
1124
+ EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
1125
+ _extends(EntityReference, Node);
1126
+ function DocumentFragment() {
1127
+ }
1128
+ DocumentFragment.prototype.nodeName = "#document-fragment";
1129
+ DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
1130
+ _extends(DocumentFragment, Node);
1131
+ function ProcessingInstruction() {
1132
+ }
1133
+ ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
1134
+ _extends(ProcessingInstruction, Node);
1135
+ function XMLSerializer() {
1136
+ }
1137
+ XMLSerializer.prototype.serializeToString = function(node, isHtml, nodeFilter) {
1138
+ return nodeSerializeToString.call(node, isHtml, nodeFilter);
1139
+ };
1140
+ Node.prototype.toString = nodeSerializeToString;
1141
+ function nodeSerializeToString(isHtml, nodeFilter) {
1142
+ var buf = [];
1143
+ var refNode = this.nodeType == 9 && this.documentElement || this;
1144
+ var prefix = refNode.prefix;
1145
+ var uri = refNode.namespaceURI;
1146
+ if (uri && prefix == null) {
1147
+ var prefix = refNode.lookupPrefix(uri);
1148
+ if (prefix == null) {
1149
+ var visibleNamespaces = [
1150
+ { namespace: uri, prefix: null }
1151
+ //{namespace:uri,prefix:''}
1152
+ ];
1153
+ }
1154
+ }
1155
+ serializeToString(this, buf, isHtml, nodeFilter, visibleNamespaces);
1156
+ return buf.join("");
1157
+ }
1158
+ function needNamespaceDefine(node, isHTML, visibleNamespaces) {
1159
+ var prefix = node.prefix || "";
1160
+ var uri = node.namespaceURI;
1161
+ if (!uri) {
1162
+ return false;
1163
+ }
1164
+ if (prefix === "xml" && uri === NAMESPACE$2.XML || uri === NAMESPACE$2.XMLNS) {
1165
+ return false;
1166
+ }
1167
+ var i = visibleNamespaces.length;
1168
+ while (i--) {
1169
+ var ns = visibleNamespaces[i];
1170
+ if (ns.prefix === prefix) {
1171
+ return ns.namespace !== uri;
1172
+ }
1173
+ }
1174
+ return true;
1175
+ }
1176
+ function addSerializedAttribute(buf, qualifiedName, value) {
1177
+ buf.push(" ", qualifiedName, '="', value.replace(/[<>&"\t\n\r]/g, _xmlEncoder), '"');
1178
+ }
1179
+ function serializeToString(node, buf, isHTML, nodeFilter, visibleNamespaces) {
1180
+ if (!visibleNamespaces) {
1181
+ visibleNamespaces = [];
1182
+ }
1183
+ if (nodeFilter) {
1184
+ node = nodeFilter(node);
1185
+ if (node) {
1186
+ if (typeof node == "string") {
1187
+ buf.push(node);
1188
+ return;
1189
+ }
1190
+ } else {
1191
+ return;
1192
+ }
1193
+ }
1194
+ switch (node.nodeType) {
1195
+ case ELEMENT_NODE:
1196
+ var attrs = node.attributes;
1197
+ var len = attrs.length;
1198
+ var child = node.firstChild;
1199
+ var nodeName = node.tagName;
1200
+ isHTML = NAMESPACE$2.isHTML(node.namespaceURI) || isHTML;
1201
+ var prefixedNodeName = nodeName;
1202
+ if (!isHTML && !node.prefix && node.namespaceURI) {
1203
+ var defaultNS;
1204
+ for (var ai = 0; ai < attrs.length; ai++) {
1205
+ if (attrs.item(ai).name === "xmlns") {
1206
+ defaultNS = attrs.item(ai).value;
1207
+ break;
1208
+ }
1209
+ }
1210
+ if (!defaultNS) {
1211
+ for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
1212
+ var namespace = visibleNamespaces[nsi];
1213
+ if (namespace.prefix === "" && namespace.namespace === node.namespaceURI) {
1214
+ defaultNS = namespace.namespace;
1215
+ break;
1216
+ }
1217
+ }
1218
+ }
1219
+ if (defaultNS !== node.namespaceURI) {
1220
+ for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
1221
+ var namespace = visibleNamespaces[nsi];
1222
+ if (namespace.namespace === node.namespaceURI) {
1223
+ if (namespace.prefix) {
1224
+ prefixedNodeName = namespace.prefix + ":" + nodeName;
1225
+ }
1226
+ break;
1227
+ }
1228
+ }
1229
+ }
1230
+ }
1231
+ buf.push("<", prefixedNodeName);
1232
+ for (var i = 0; i < len; i++) {
1233
+ var attr = attrs.item(i);
1234
+ if (attr.prefix == "xmlns") {
1235
+ visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
1236
+ } else if (attr.nodeName == "xmlns") {
1237
+ visibleNamespaces.push({ prefix: "", namespace: attr.value });
1238
+ }
1239
+ }
1240
+ for (var i = 0; i < len; i++) {
1241
+ var attr = attrs.item(i);
1242
+ if (needNamespaceDefine(attr, isHTML, visibleNamespaces)) {
1243
+ var prefix = attr.prefix || "";
1244
+ var uri = attr.namespaceURI;
1245
+ addSerializedAttribute(buf, prefix ? "xmlns:" + prefix : "xmlns", uri);
1246
+ visibleNamespaces.push({ prefix, namespace: uri });
1247
+ }
1248
+ serializeToString(attr, buf, isHTML, nodeFilter, visibleNamespaces);
1249
+ }
1250
+ if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {
1251
+ var prefix = node.prefix || "";
1252
+ var uri = node.namespaceURI;
1253
+ addSerializedAttribute(buf, prefix ? "xmlns:" + prefix : "xmlns", uri);
1254
+ visibleNamespaces.push({ prefix, namespace: uri });
1255
+ }
1256
+ if (child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)) {
1257
+ buf.push(">");
1258
+ if (isHTML && /^script$/i.test(nodeName)) {
1259
+ while (child) {
1260
+ if (child.data) {
1261
+ buf.push(child.data);
1262
+ } else {
1263
+ serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
1264
+ }
1265
+ child = child.nextSibling;
1266
+ }
1267
+ } else {
1268
+ while (child) {
1269
+ serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
1270
+ child = child.nextSibling;
1271
+ }
1272
+ }
1273
+ buf.push("</", prefixedNodeName, ">");
1274
+ } else {
1275
+ buf.push("/>");
1276
+ }
1277
+ return;
1278
+ case DOCUMENT_NODE:
1279
+ case DOCUMENT_FRAGMENT_NODE:
1280
+ var child = node.firstChild;
1281
+ while (child) {
1282
+ serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
1283
+ child = child.nextSibling;
1284
+ }
1285
+ return;
1286
+ case ATTRIBUTE_NODE:
1287
+ return addSerializedAttribute(buf, node.name, node.value);
1288
+ case TEXT_NODE:
1289
+ return buf.push(
1290
+ node.data.replace(/[<&>]/g, _xmlEncoder)
1291
+ );
1292
+ case CDATA_SECTION_NODE:
1293
+ return buf.push("<![CDATA[", node.data, "]]>");
1294
+ case COMMENT_NODE:
1295
+ return buf.push("<!--", node.data, "-->");
1296
+ case DOCUMENT_TYPE_NODE:
1297
+ var pubid = node.publicId;
1298
+ var sysid = node.systemId;
1299
+ buf.push("<!DOCTYPE ", node.name);
1300
+ if (pubid) {
1301
+ buf.push(" PUBLIC ", pubid);
1302
+ if (sysid && sysid != ".") {
1303
+ buf.push(" ", sysid);
1304
+ }
1305
+ buf.push(">");
1306
+ } else if (sysid && sysid != ".") {
1307
+ buf.push(" SYSTEM ", sysid, ">");
1308
+ } else {
1309
+ var sub = node.internalSubset;
1310
+ if (sub) {
1311
+ buf.push(" [", sub, "]");
1312
+ }
1313
+ buf.push(">");
1314
+ }
1315
+ return;
1316
+ case PROCESSING_INSTRUCTION_NODE:
1317
+ return buf.push("<?", node.target, " ", node.data, "?>");
1318
+ case ENTITY_REFERENCE_NODE:
1319
+ return buf.push("&", node.nodeName, ";");
1320
+ default:
1321
+ buf.push("??", node.nodeName);
1322
+ }
1323
+ }
1324
+ function importNode(doc, node, deep) {
1325
+ var node2;
1326
+ switch (node.nodeType) {
1327
+ case ELEMENT_NODE:
1328
+ node2 = node.cloneNode(false);
1329
+ node2.ownerDocument = doc;
1330
+ case DOCUMENT_FRAGMENT_NODE:
1331
+ break;
1332
+ case ATTRIBUTE_NODE:
1333
+ deep = true;
1334
+ break;
1335
+ }
1336
+ if (!node2) {
1337
+ node2 = node.cloneNode(false);
1338
+ }
1339
+ node2.ownerDocument = doc;
1340
+ node2.parentNode = null;
1341
+ if (deep) {
1342
+ var child = node.firstChild;
1343
+ while (child) {
1344
+ node2.appendChild(importNode(doc, child, deep));
1345
+ child = child.nextSibling;
1346
+ }
1347
+ }
1348
+ return node2;
1349
+ }
1350
+ function cloneNode(doc, node, deep) {
1351
+ var node2 = new node.constructor();
1352
+ for (var n in node) {
1353
+ if (Object.prototype.hasOwnProperty.call(node, n)) {
1354
+ var v = node[n];
1355
+ if (typeof v != "object") {
1356
+ if (v != node2[n]) {
1357
+ node2[n] = v;
1358
+ }
1359
+ }
1360
+ }
1361
+ }
1362
+ if (node.childNodes) {
1363
+ node2.childNodes = new NodeList();
1364
+ }
1365
+ node2.ownerDocument = doc;
1366
+ switch (node2.nodeType) {
1367
+ case ELEMENT_NODE:
1368
+ var attrs = node.attributes;
1369
+ var attrs2 = node2.attributes = new NamedNodeMap();
1370
+ var len = attrs.length;
1371
+ attrs2._ownerElement = node2;
1372
+ for (var i = 0; i < len; i++) {
1373
+ node2.setAttributeNode(cloneNode(doc, attrs.item(i), true));
1374
+ }
1375
+ break;
1376
+ case ATTRIBUTE_NODE:
1377
+ deep = true;
1378
+ }
1379
+ if (deep) {
1380
+ var child = node.firstChild;
1381
+ while (child) {
1382
+ node2.appendChild(cloneNode(doc, child, deep));
1383
+ child = child.nextSibling;
1384
+ }
1385
+ }
1386
+ return node2;
1387
+ }
1388
+ function __set__(object, key, value) {
1389
+ object[key] = value;
1390
+ }
1391
+ try {
1392
+ if (Object.defineProperty) {
1393
+ let getTextContent = function(node) {
1394
+ switch (node.nodeType) {
1395
+ case ELEMENT_NODE:
1396
+ case DOCUMENT_FRAGMENT_NODE:
1397
+ var buf = [];
1398
+ node = node.firstChild;
1399
+ while (node) {
1400
+ if (node.nodeType !== 7 && node.nodeType !== 8) {
1401
+ buf.push(getTextContent(node));
1402
+ }
1403
+ node = node.nextSibling;
1404
+ }
1405
+ return buf.join("");
1406
+ default:
1407
+ return node.nodeValue;
1408
+ }
1409
+ };
1410
+ Object.defineProperty(LiveNodeList.prototype, "length", {
1411
+ get: function() {
1412
+ _updateLiveList(this);
1413
+ return this.$$length;
1414
+ }
1415
+ });
1416
+ Object.defineProperty(Node.prototype, "textContent", {
1417
+ get: function() {
1418
+ return getTextContent(this);
1419
+ },
1420
+ set: function(data) {
1421
+ switch (this.nodeType) {
1422
+ case ELEMENT_NODE:
1423
+ case DOCUMENT_FRAGMENT_NODE:
1424
+ while (this.firstChild) {
1425
+ this.removeChild(this.firstChild);
1426
+ }
1427
+ if (data || String(data)) {
1428
+ this.appendChild(this.ownerDocument.createTextNode(data));
1429
+ }
1430
+ break;
1431
+ default:
1432
+ this.data = data;
1433
+ this.value = data;
1434
+ this.nodeValue = data;
1435
+ }
1436
+ }
1437
+ });
1438
+ __set__ = function(object, key, value) {
1439
+ object["$$" + key] = value;
1440
+ };
1441
+ }
1442
+ } catch (e) {
1443
+ }
1444
+ dom$1.DocumentType = DocumentType;
1445
+ dom$1.DOMException = DOMException;
1446
+ dom$1.DOMImplementation = DOMImplementation$1;
1447
+ dom$1.Element = Element;
1448
+ dom$1.Node = Node;
1449
+ dom$1.NodeList = NodeList;
1450
+ dom$1.XMLSerializer = XMLSerializer;
1451
+ var domParser = {};
1452
+ var entities$1 = {};
1453
+ (function(exports) {
1454
+ var freeze2 = conventions$2.freeze;
1455
+ exports.XML_ENTITIES = freeze2({ amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' });
1456
+ exports.HTML_ENTITIES = freeze2({
1457
+ lt: "<",
1458
+ gt: ">",
1459
+ amp: "&",
1460
+ quot: '"',
1461
+ apos: "'",
1462
+ Agrave: "À",
1463
+ Aacute: "Á",
1464
+ Acirc: "Â",
1465
+ Atilde: "Ã",
1466
+ Auml: "Ä",
1467
+ Aring: "Å",
1468
+ AElig: "Æ",
1469
+ Ccedil: "Ç",
1470
+ Egrave: "È",
1471
+ Eacute: "É",
1472
+ Ecirc: "Ê",
1473
+ Euml: "Ë",
1474
+ Igrave: "Ì",
1475
+ Iacute: "Í",
1476
+ Icirc: "Î",
1477
+ Iuml: "Ï",
1478
+ ETH: "Ð",
1479
+ Ntilde: "Ñ",
1480
+ Ograve: "Ò",
1481
+ Oacute: "Ó",
1482
+ Ocirc: "Ô",
1483
+ Otilde: "Õ",
1484
+ Ouml: "Ö",
1485
+ Oslash: "Ø",
1486
+ Ugrave: "Ù",
1487
+ Uacute: "Ú",
1488
+ Ucirc: "Û",
1489
+ Uuml: "Ü",
1490
+ Yacute: "Ý",
1491
+ THORN: "Þ",
1492
+ szlig: "ß",
1493
+ agrave: "à",
1494
+ aacute: "á",
1495
+ acirc: "â",
1496
+ atilde: "ã",
1497
+ auml: "ä",
1498
+ aring: "å",
1499
+ aelig: "æ",
1500
+ ccedil: "ç",
1501
+ egrave: "è",
1502
+ eacute: "é",
1503
+ ecirc: "ê",
1504
+ euml: "ë",
1505
+ igrave: "ì",
1506
+ iacute: "í",
1507
+ icirc: "î",
1508
+ iuml: "ï",
1509
+ eth: "ð",
1510
+ ntilde: "ñ",
1511
+ ograve: "ò",
1512
+ oacute: "ó",
1513
+ ocirc: "ô",
1514
+ otilde: "õ",
1515
+ ouml: "ö",
1516
+ oslash: "ø",
1517
+ ugrave: "ù",
1518
+ uacute: "ú",
1519
+ ucirc: "û",
1520
+ uuml: "ü",
1521
+ yacute: "ý",
1522
+ thorn: "þ",
1523
+ yuml: "ÿ",
1524
+ nbsp: " ",
1525
+ iexcl: "¡",
1526
+ cent: "¢",
1527
+ pound: "£",
1528
+ curren: "¤",
1529
+ yen: "¥",
1530
+ brvbar: "¦",
1531
+ sect: "§",
1532
+ uml: "¨",
1533
+ copy: "©",
1534
+ ordf: "ª",
1535
+ laquo: "«",
1536
+ not: "¬",
1537
+ shy: "­­",
1538
+ reg: "®",
1539
+ macr: "¯",
1540
+ deg: "°",
1541
+ plusmn: "±",
1542
+ sup2: "²",
1543
+ sup3: "³",
1544
+ acute: "´",
1545
+ micro: "µ",
1546
+ para: "¶",
1547
+ middot: "·",
1548
+ cedil: "¸",
1549
+ sup1: "¹",
1550
+ ordm: "º",
1551
+ raquo: "»",
1552
+ frac14: "¼",
1553
+ frac12: "½",
1554
+ frac34: "¾",
1555
+ iquest: "¿",
1556
+ times: "×",
1557
+ divide: "÷",
1558
+ forall: "∀",
1559
+ part: "∂",
1560
+ exist: "∃",
1561
+ empty: "∅",
1562
+ nabla: "∇",
1563
+ isin: "∈",
1564
+ notin: "∉",
1565
+ ni: "∋",
1566
+ prod: "∏",
1567
+ sum: "∑",
1568
+ minus: "−",
1569
+ lowast: "∗",
1570
+ radic: "√",
1571
+ prop: "∝",
1572
+ infin: "∞",
1573
+ ang: "∠",
1574
+ and: "∧",
1575
+ or: "∨",
1576
+ cap: "∩",
1577
+ cup: "∪",
1578
+ "int": "∫",
1579
+ there4: "∴",
1580
+ sim: "∼",
1581
+ cong: "≅",
1582
+ asymp: "≈",
1583
+ ne: "≠",
1584
+ equiv: "≡",
1585
+ le: "≤",
1586
+ ge: "≥",
1587
+ sub: "⊂",
1588
+ sup: "⊃",
1589
+ nsub: "⊄",
1590
+ sube: "⊆",
1591
+ supe: "⊇",
1592
+ oplus: "⊕",
1593
+ otimes: "⊗",
1594
+ perp: "⊥",
1595
+ sdot: "⋅",
1596
+ Alpha: "Α",
1597
+ Beta: "Β",
1598
+ Gamma: "Γ",
1599
+ Delta: "Δ",
1600
+ Epsilon: "Ε",
1601
+ Zeta: "Ζ",
1602
+ Eta: "Η",
1603
+ Theta: "Θ",
1604
+ Iota: "Ι",
1605
+ Kappa: "Κ",
1606
+ Lambda: "Λ",
1607
+ Mu: "Μ",
1608
+ Nu: "Ν",
1609
+ Xi: "Ξ",
1610
+ Omicron: "Ο",
1611
+ Pi: "Π",
1612
+ Rho: "Ρ",
1613
+ Sigma: "Σ",
1614
+ Tau: "Τ",
1615
+ Upsilon: "Υ",
1616
+ Phi: "Φ",
1617
+ Chi: "Χ",
1618
+ Psi: "Ψ",
1619
+ Omega: "Ω",
1620
+ alpha: "α",
1621
+ beta: "β",
1622
+ gamma: "γ",
1623
+ delta: "δ",
1624
+ epsilon: "ε",
1625
+ zeta: "ζ",
1626
+ eta: "η",
1627
+ theta: "θ",
1628
+ iota: "ι",
1629
+ kappa: "κ",
1630
+ lambda: "λ",
1631
+ mu: "μ",
1632
+ nu: "ν",
1633
+ xi: "ξ",
1634
+ omicron: "ο",
1635
+ pi: "π",
1636
+ rho: "ρ",
1637
+ sigmaf: "ς",
1638
+ sigma: "σ",
1639
+ tau: "τ",
1640
+ upsilon: "υ",
1641
+ phi: "φ",
1642
+ chi: "χ",
1643
+ psi: "ψ",
1644
+ omega: "ω",
1645
+ thetasym: "ϑ",
1646
+ upsih: "ϒ",
1647
+ piv: "ϖ",
1648
+ OElig: "Œ",
1649
+ oelig: "œ",
1650
+ Scaron: "Š",
1651
+ scaron: "š",
1652
+ Yuml: "Ÿ",
1653
+ fnof: "ƒ",
1654
+ circ: "ˆ",
1655
+ tilde: "˜",
1656
+ ensp: " ",
1657
+ emsp: " ",
1658
+ thinsp: " ",
1659
+ zwnj: "‌",
1660
+ zwj: "‍",
1661
+ lrm: "‎",
1662
+ rlm: "‏",
1663
+ ndash: "–",
1664
+ mdash: "—",
1665
+ lsquo: "‘",
1666
+ rsquo: "’",
1667
+ sbquo: "‚",
1668
+ ldquo: "“",
1669
+ rdquo: "”",
1670
+ bdquo: "„",
1671
+ dagger: "†",
1672
+ Dagger: "‡",
1673
+ bull: "•",
1674
+ hellip: "…",
1675
+ permil: "‰",
1676
+ prime: "′",
1677
+ Prime: "″",
1678
+ lsaquo: "‹",
1679
+ rsaquo: "›",
1680
+ oline: "‾",
1681
+ euro: "€",
1682
+ trade: "™",
1683
+ larr: "←",
1684
+ uarr: "↑",
1685
+ rarr: "→",
1686
+ darr: "↓",
1687
+ harr: "↔",
1688
+ crarr: "↵",
1689
+ lceil: "⌈",
1690
+ rceil: "⌉",
1691
+ lfloor: "⌊",
1692
+ rfloor: "⌋",
1693
+ loz: "◊",
1694
+ spades: "♠",
1695
+ clubs: "♣",
1696
+ hearts: "♥",
1697
+ diams: "♦"
1698
+ });
1699
+ exports.entityMap = exports.HTML_ENTITIES;
1700
+ })(entities$1);
1701
+ var sax$1 = {};
1702
+ var NAMESPACE$1 = conventions$2.NAMESPACE;
1703
+ var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
1704
+ var nameChar = new RegExp("[\\-\\.0-9" + nameStartChar.source.slice(1, -1) + "\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
1705
+ var tagNamePattern = new RegExp("^" + nameStartChar.source + nameChar.source + "*(?::" + nameStartChar.source + nameChar.source + "*)?$");
1706
+ var S_TAG = 0;
1707
+ var S_ATTR = 1;
1708
+ var S_ATTR_SPACE = 2;
1709
+ var S_EQ = 3;
1710
+ var S_ATTR_NOQUOT_VALUE = 4;
1711
+ var S_ATTR_END = 5;
1712
+ var S_TAG_SPACE = 6;
1713
+ var S_TAG_CLOSE = 7;
1714
+ function ParseError$1(message, locator) {
1715
+ this.message = message;
1716
+ this.locator = locator;
1717
+ if (Error.captureStackTrace)
1718
+ Error.captureStackTrace(this, ParseError$1);
1719
+ }
1720
+ ParseError$1.prototype = new Error();
1721
+ ParseError$1.prototype.name = ParseError$1.name;
1722
+ function XMLReader$1() {
1723
+ }
1724
+ XMLReader$1.prototype = {
1725
+ parse: function(source, defaultNSMap, entityMap) {
1726
+ var domBuilder = this.domBuilder;
1727
+ domBuilder.startDocument();
1728
+ _copy(defaultNSMap, defaultNSMap = {});
1729
+ parse(
1730
+ source,
1731
+ defaultNSMap,
1732
+ entityMap,
1733
+ domBuilder,
1734
+ this.errorHandler
1735
+ );
1736
+ domBuilder.endDocument();
1737
+ }
1738
+ };
1739
+ function parse(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {
1740
+ function fixedFromCharCode(code) {
1741
+ if (code > 65535) {
1742
+ code -= 65536;
1743
+ var surrogate1 = 55296 + (code >> 10), surrogate2 = 56320 + (code & 1023);
1744
+ return String.fromCharCode(surrogate1, surrogate2);
1745
+ } else {
1746
+ return String.fromCharCode(code);
1747
+ }
1748
+ }
1749
+ function entityReplacer(a2) {
1750
+ var k = a2.slice(1, -1);
1751
+ if (Object.hasOwnProperty.call(entityMap, k)) {
1752
+ return entityMap[k];
1753
+ } else if (k.charAt(0) === "#") {
1754
+ return fixedFromCharCode(parseInt(k.substr(1).replace("x", "0x")));
1755
+ } else {
1756
+ errorHandler.error("entity not found:" + a2);
1757
+ return a2;
1758
+ }
1759
+ }
1760
+ function appendText(end2) {
1761
+ if (end2 > start) {
1762
+ var xt = source.substring(start, end2).replace(/&#?\w+;/g, entityReplacer);
1763
+ locator && position2(start);
1764
+ domBuilder.characters(xt, 0, end2 - start);
1765
+ start = end2;
1766
+ }
1767
+ }
1768
+ function position2(p, m) {
1769
+ while (p >= lineEnd && (m = linePattern.exec(source))) {
1770
+ lineStart = m.index;
1771
+ lineEnd = lineStart + m[0].length;
1772
+ locator.lineNumber++;
1773
+ }
1774
+ locator.columnNumber = p - lineStart + 1;
1775
+ }
1776
+ var lineStart = 0;
1777
+ var lineEnd = 0;
1778
+ var linePattern = /.*(?:\r\n?|\n)|.*$/g;
1779
+ var locator = domBuilder.locator;
1780
+ var parseStack = [{ currentNSMap: defaultNSMapCopy }];
1781
+ var closeMap = {};
1782
+ var start = 0;
1783
+ while (true) {
1784
+ try {
1785
+ var tagStart = source.indexOf("<", start);
1786
+ if (tagStart < 0) {
1787
+ if (!source.substr(start).match(/^\s*$/)) {
1788
+ var doc = domBuilder.doc;
1789
+ var text = doc.createTextNode(source.substr(start));
1790
+ doc.appendChild(text);
1791
+ domBuilder.currentElement = text;
1792
+ }
1793
+ return;
1794
+ }
1795
+ if (tagStart > start) {
1796
+ appendText(tagStart);
1797
+ }
1798
+ switch (source.charAt(tagStart + 1)) {
1799
+ case "/":
1800
+ var end = source.indexOf(">", tagStart + 3);
1801
+ var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, "");
1802
+ var config = parseStack.pop();
1803
+ if (end < 0) {
1804
+ tagName = source.substring(tagStart + 2).replace(/[\s<].*/, "");
1805
+ errorHandler.error("end tag name: " + tagName + " is not complete:" + config.tagName);
1806
+ end = tagStart + 1 + tagName.length;
1807
+ } else if (tagName.match(/\s</)) {
1808
+ tagName = tagName.replace(/[\s<].*/, "");
1809
+ errorHandler.error("end tag name: " + tagName + " maybe not complete");
1810
+ end = tagStart + 1 + tagName.length;
1811
+ }
1812
+ var localNSMap = config.localNSMap;
1813
+ var endMatch = config.tagName == tagName;
1814
+ var endIgnoreCaseMach = endMatch || config.tagName && config.tagName.toLowerCase() == tagName.toLowerCase();
1815
+ if (endIgnoreCaseMach) {
1816
+ domBuilder.endElement(config.uri, config.localName, tagName);
1817
+ if (localNSMap) {
1818
+ for (var prefix in localNSMap) {
1819
+ if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
1820
+ domBuilder.endPrefixMapping(prefix);
1821
+ }
1822
+ }
1823
+ }
1824
+ if (!endMatch) {
1825
+ errorHandler.fatalError("end tag name: " + tagName + " is not match the current start tagName:" + config.tagName);
1826
+ }
1827
+ } else {
1828
+ parseStack.push(config);
1829
+ }
1830
+ end++;
1831
+ break;
1832
+ case "?":
1833
+ locator && position2(tagStart);
1834
+ end = parseInstruction(source, tagStart, domBuilder);
1835
+ break;
1836
+ case "!":
1837
+ locator && position2(tagStart);
1838
+ end = parseDCC(source, tagStart, domBuilder, errorHandler);
1839
+ break;
1840
+ default:
1841
+ locator && position2(tagStart);
1842
+ var el = new ElementAttributes();
1843
+ var currentNSMap = parseStack[parseStack.length - 1].currentNSMap;
1844
+ var end = parseElementStartPart(source, tagStart, el, currentNSMap, entityReplacer, errorHandler);
1845
+ var len = el.length;
1846
+ if (!el.closed && fixSelfClosed(source, end, el.tagName, closeMap)) {
1847
+ el.closed = true;
1848
+ if (!entityMap.nbsp) {
1849
+ errorHandler.warning("unclosed xml attribute");
1850
+ }
1851
+ }
1852
+ if (locator && len) {
1853
+ var locator2 = copyLocator(locator, {});
1854
+ for (var i = 0; i < len; i++) {
1855
+ var a = el[i];
1856
+ position2(a.offset);
1857
+ a.locator = copyLocator(locator, {});
1858
+ }
1859
+ domBuilder.locator = locator2;
1860
+ if (appendElement$1(el, domBuilder, currentNSMap)) {
1861
+ parseStack.push(el);
1862
+ }
1863
+ domBuilder.locator = locator;
1864
+ } else {
1865
+ if (appendElement$1(el, domBuilder, currentNSMap)) {
1866
+ parseStack.push(el);
1867
+ }
1868
+ }
1869
+ if (NAMESPACE$1.isHTML(el.uri) && !el.closed) {
1870
+ end = parseHtmlSpecialContent(source, end, el.tagName, entityReplacer, domBuilder);
1871
+ } else {
1872
+ end++;
1873
+ }
1874
+ }
1875
+ } catch (e) {
1876
+ if (e instanceof ParseError$1) {
1877
+ throw e;
1878
+ }
1879
+ errorHandler.error("element parse error: " + e);
1880
+ end = -1;
1881
+ }
1882
+ if (end > start) {
1883
+ start = end;
1884
+ } else {
1885
+ appendText(Math.max(tagStart, start) + 1);
1886
+ }
1887
+ }
1888
+ }
1889
+ function copyLocator(f, t) {
1890
+ t.lineNumber = f.lineNumber;
1891
+ t.columnNumber = f.columnNumber;
1892
+ return t;
1893
+ }
1894
+ function parseElementStartPart(source, start, el, currentNSMap, entityReplacer, errorHandler) {
1895
+ function addAttribute(qname, value2, startIndex) {
1896
+ if (el.attributeNames.hasOwnProperty(qname)) {
1897
+ errorHandler.fatalError("Attribute " + qname + " redefined");
1898
+ }
1899
+ el.addValue(
1900
+ qname,
1901
+ // @see https://www.w3.org/TR/xml/#AVNormalize
1902
+ // since the xmldom sax parser does not "interpret" DTD the following is not implemented:
1903
+ // - recursive replacement of (DTD) entity references
1904
+ // - trimming and collapsing multiple spaces into a single one for attributes that are not of type CDATA
1905
+ value2.replace(/[\t\n\r]/g, " ").replace(/&#?\w+;/g, entityReplacer),
1906
+ startIndex
1907
+ );
1908
+ }
1909
+ var attrName;
1910
+ var value;
1911
+ var p = ++start;
1912
+ var s = S_TAG;
1913
+ while (true) {
1914
+ var c = source.charAt(p);
1915
+ switch (c) {
1916
+ case "=":
1917
+ if (s === S_ATTR) {
1918
+ attrName = source.slice(start, p);
1919
+ s = S_EQ;
1920
+ } else if (s === S_ATTR_SPACE) {
1921
+ s = S_EQ;
1922
+ } else {
1923
+ throw new Error("attribute equal must after attrName");
1924
+ }
1925
+ break;
1926
+ case "'":
1927
+ case '"':
1928
+ if (s === S_EQ || s === S_ATTR) {
1929
+ if (s === S_ATTR) {
1930
+ errorHandler.warning('attribute value must after "="');
1931
+ attrName = source.slice(start, p);
1932
+ }
1933
+ start = p + 1;
1934
+ p = source.indexOf(c, start);
1935
+ if (p > 0) {
1936
+ value = source.slice(start, p);
1937
+ addAttribute(attrName, value, start - 1);
1938
+ s = S_ATTR_END;
1939
+ } else {
1940
+ throw new Error("attribute value no end '" + c + "' match");
1941
+ }
1942
+ } else if (s == S_ATTR_NOQUOT_VALUE) {
1943
+ value = source.slice(start, p);
1944
+ addAttribute(attrName, value, start);
1945
+ errorHandler.warning('attribute "' + attrName + '" missed start quot(' + c + ")!!");
1946
+ start = p + 1;
1947
+ s = S_ATTR_END;
1948
+ } else {
1949
+ throw new Error('attribute value must after "="');
1950
+ }
1951
+ break;
1952
+ case "/":
1953
+ switch (s) {
1954
+ case S_TAG:
1955
+ el.setTagName(source.slice(start, p));
1956
+ case S_ATTR_END:
1957
+ case S_TAG_SPACE:
1958
+ case S_TAG_CLOSE:
1959
+ s = S_TAG_CLOSE;
1960
+ el.closed = true;
1961
+ case S_ATTR_NOQUOT_VALUE:
1962
+ case S_ATTR:
1963
+ case S_ATTR_SPACE:
1964
+ break;
1965
+ default:
1966
+ throw new Error("attribute invalid close char('/')");
1967
+ }
1968
+ break;
1969
+ case "":
1970
+ errorHandler.error("unexpected end of input");
1971
+ if (s == S_TAG) {
1972
+ el.setTagName(source.slice(start, p));
1973
+ }
1974
+ return p;
1975
+ case ">":
1976
+ switch (s) {
1977
+ case S_TAG:
1978
+ el.setTagName(source.slice(start, p));
1979
+ case S_ATTR_END:
1980
+ case S_TAG_SPACE:
1981
+ case S_TAG_CLOSE:
1982
+ break;
1983
+ case S_ATTR_NOQUOT_VALUE:
1984
+ case S_ATTR:
1985
+ value = source.slice(start, p);
1986
+ if (value.slice(-1) === "/") {
1987
+ el.closed = true;
1988
+ value = value.slice(0, -1);
1989
+ }
1990
+ case S_ATTR_SPACE:
1991
+ if (s === S_ATTR_SPACE) {
1992
+ value = attrName;
1993
+ }
1994
+ if (s == S_ATTR_NOQUOT_VALUE) {
1995
+ errorHandler.warning('attribute "' + value + '" missed quot(")!');
1996
+ addAttribute(attrName, value, start);
1997
+ } else {
1998
+ if (!NAMESPACE$1.isHTML(currentNSMap[""]) || !value.match(/^(?:disabled|checked|selected)$/i)) {
1999
+ errorHandler.warning('attribute "' + value + '" missed value!! "' + value + '" instead!!');
2000
+ }
2001
+ addAttribute(value, value, start);
2002
+ }
2003
+ break;
2004
+ case S_EQ:
2005
+ throw new Error("attribute value missed!!");
2006
+ }
2007
+ return p;
2008
+ case "€":
2009
+ c = " ";
2010
+ default:
2011
+ if (c <= " ") {
2012
+ switch (s) {
2013
+ case S_TAG:
2014
+ el.setTagName(source.slice(start, p));
2015
+ s = S_TAG_SPACE;
2016
+ break;
2017
+ case S_ATTR:
2018
+ attrName = source.slice(start, p);
2019
+ s = S_ATTR_SPACE;
2020
+ break;
2021
+ case S_ATTR_NOQUOT_VALUE:
2022
+ var value = source.slice(start, p);
2023
+ errorHandler.warning('attribute "' + value + '" missed quot(")!!');
2024
+ addAttribute(attrName, value, start);
2025
+ case S_ATTR_END:
2026
+ s = S_TAG_SPACE;
2027
+ break;
2028
+ }
2029
+ } else {
2030
+ switch (s) {
2031
+ case S_ATTR_SPACE:
2032
+ el.tagName;
2033
+ if (!NAMESPACE$1.isHTML(currentNSMap[""]) || !attrName.match(/^(?:disabled|checked|selected)$/i)) {
2034
+ errorHandler.warning('attribute "' + attrName + '" missed value!! "' + attrName + '" instead2!!');
2035
+ }
2036
+ addAttribute(attrName, attrName, start);
2037
+ start = p;
2038
+ s = S_ATTR;
2039
+ break;
2040
+ case S_ATTR_END:
2041
+ errorHandler.warning('attribute space is required"' + attrName + '"!!');
2042
+ case S_TAG_SPACE:
2043
+ s = S_ATTR;
2044
+ start = p;
2045
+ break;
2046
+ case S_EQ:
2047
+ s = S_ATTR_NOQUOT_VALUE;
2048
+ start = p;
2049
+ break;
2050
+ case S_TAG_CLOSE:
2051
+ throw new Error("elements closed character '/' and '>' must be connected to");
2052
+ }
2053
+ }
2054
+ }
2055
+ p++;
2056
+ }
2057
+ }
2058
+ function appendElement$1(el, domBuilder, currentNSMap) {
2059
+ var tagName = el.tagName;
2060
+ var localNSMap = null;
2061
+ var i = el.length;
2062
+ while (i--) {
2063
+ var a = el[i];
2064
+ var qName = a.qName;
2065
+ var value = a.value;
2066
+ var nsp = qName.indexOf(":");
2067
+ if (nsp > 0) {
2068
+ var prefix = a.prefix = qName.slice(0, nsp);
2069
+ var localName = qName.slice(nsp + 1);
2070
+ var nsPrefix = prefix === "xmlns" && localName;
2071
+ } else {
2072
+ localName = qName;
2073
+ prefix = null;
2074
+ nsPrefix = qName === "xmlns" && "";
2075
+ }
2076
+ a.localName = localName;
2077
+ if (nsPrefix !== false) {
2078
+ if (localNSMap == null) {
2079
+ localNSMap = {};
2080
+ _copy(currentNSMap, currentNSMap = {});
2081
+ }
2082
+ currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
2083
+ a.uri = NAMESPACE$1.XMLNS;
2084
+ domBuilder.startPrefixMapping(nsPrefix, value);
2085
+ }
2086
+ }
2087
+ var i = el.length;
2088
+ while (i--) {
2089
+ a = el[i];
2090
+ var prefix = a.prefix;
2091
+ if (prefix) {
2092
+ if (prefix === "xml") {
2093
+ a.uri = NAMESPACE$1.XML;
2094
+ }
2095
+ if (prefix !== "xmlns") {
2096
+ a.uri = currentNSMap[prefix || ""];
2097
+ }
2098
+ }
2099
+ }
2100
+ var nsp = tagName.indexOf(":");
2101
+ if (nsp > 0) {
2102
+ prefix = el.prefix = tagName.slice(0, nsp);
2103
+ localName = el.localName = tagName.slice(nsp + 1);
2104
+ } else {
2105
+ prefix = null;
2106
+ localName = el.localName = tagName;
2107
+ }
2108
+ var ns = el.uri = currentNSMap[prefix || ""];
2109
+ domBuilder.startElement(ns, localName, tagName, el);
2110
+ if (el.closed) {
2111
+ domBuilder.endElement(ns, localName, tagName);
2112
+ if (localNSMap) {
2113
+ for (prefix in localNSMap) {
2114
+ if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
2115
+ domBuilder.endPrefixMapping(prefix);
2116
+ }
2117
+ }
2118
+ }
2119
+ } else {
2120
+ el.currentNSMap = currentNSMap;
2121
+ el.localNSMap = localNSMap;
2122
+ return true;
2123
+ }
2124
+ }
2125
+ function parseHtmlSpecialContent(source, elStartEnd, tagName, entityReplacer, domBuilder) {
2126
+ if (/^(?:script|textarea)$/i.test(tagName)) {
2127
+ var elEndStart = source.indexOf("</" + tagName + ">", elStartEnd);
2128
+ var text = source.substring(elStartEnd + 1, elEndStart);
2129
+ if (/[&<]/.test(text)) {
2130
+ if (/^script$/i.test(tagName)) {
2131
+ domBuilder.characters(text, 0, text.length);
2132
+ return elEndStart;
2133
+ }
2134
+ text = text.replace(/&#?\w+;/g, entityReplacer);
2135
+ domBuilder.characters(text, 0, text.length);
2136
+ return elEndStart;
2137
+ }
2138
+ }
2139
+ return elStartEnd + 1;
2140
+ }
2141
+ function fixSelfClosed(source, elStartEnd, tagName, closeMap) {
2142
+ var pos = closeMap[tagName];
2143
+ if (pos == null) {
2144
+ pos = source.lastIndexOf("</" + tagName + ">");
2145
+ if (pos < elStartEnd) {
2146
+ pos = source.lastIndexOf("</" + tagName);
2147
+ }
2148
+ closeMap[tagName] = pos;
2149
+ }
2150
+ return pos < elStartEnd;
2151
+ }
2152
+ function _copy(source, target) {
2153
+ for (var n in source) {
2154
+ if (Object.prototype.hasOwnProperty.call(source, n)) {
2155
+ target[n] = source[n];
2156
+ }
2157
+ }
2158
+ }
2159
+ function parseDCC(source, start, domBuilder, errorHandler) {
2160
+ var next = source.charAt(start + 2);
2161
+ switch (next) {
2162
+ case "-":
2163
+ if (source.charAt(start + 3) === "-") {
2164
+ var end = source.indexOf("-->", start + 4);
2165
+ if (end > start) {
2166
+ domBuilder.comment(source, start + 4, end - start - 4);
2167
+ return end + 3;
2168
+ } else {
2169
+ errorHandler.error("Unclosed comment");
2170
+ return -1;
2171
+ }
2172
+ } else {
2173
+ return -1;
2174
+ }
2175
+ default:
2176
+ if (source.substr(start + 3, 6) == "CDATA[") {
2177
+ var end = source.indexOf("]]>", start + 9);
2178
+ domBuilder.startCDATA();
2179
+ domBuilder.characters(source, start + 9, end - start - 9);
2180
+ domBuilder.endCDATA();
2181
+ return end + 3;
2182
+ }
2183
+ var matchs = split(source, start);
2184
+ var len = matchs.length;
2185
+ if (len > 1 && /!doctype/i.test(matchs[0][0])) {
2186
+ var name = matchs[1][0];
2187
+ var pubid = false;
2188
+ var sysid = false;
2189
+ if (len > 3) {
2190
+ if (/^public$/i.test(matchs[2][0])) {
2191
+ pubid = matchs[3][0];
2192
+ sysid = len > 4 && matchs[4][0];
2193
+ } else if (/^system$/i.test(matchs[2][0])) {
2194
+ sysid = matchs[3][0];
2195
+ }
2196
+ }
2197
+ var lastMatch = matchs[len - 1];
2198
+ domBuilder.startDTD(name, pubid, sysid);
2199
+ domBuilder.endDTD();
2200
+ return lastMatch.index + lastMatch[0].length;
2201
+ }
2202
+ }
2203
+ return -1;
2204
+ }
2205
+ function parseInstruction(source, start, domBuilder) {
2206
+ var end = source.indexOf("?>", start);
2207
+ if (end) {
2208
+ var match = source.substring(start, end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
2209
+ if (match) {
2210
+ match[0].length;
2211
+ domBuilder.processingInstruction(match[1], match[2]);
2212
+ return end + 2;
2213
+ } else {
2214
+ return -1;
2215
+ }
2216
+ }
2217
+ return -1;
2218
+ }
2219
+ function ElementAttributes() {
2220
+ this.attributeNames = {};
2221
+ }
2222
+ ElementAttributes.prototype = {
2223
+ setTagName: function(tagName) {
2224
+ if (!tagNamePattern.test(tagName)) {
2225
+ throw new Error("invalid tagName:" + tagName);
2226
+ }
2227
+ this.tagName = tagName;
2228
+ },
2229
+ addValue: function(qName, value, offset) {
2230
+ if (!tagNamePattern.test(qName)) {
2231
+ throw new Error("invalid attribute:" + qName);
2232
+ }
2233
+ this.attributeNames[qName] = this.length;
2234
+ this[this.length++] = { qName, value, offset };
2235
+ },
2236
+ length: 0,
2237
+ getLocalName: function(i) {
2238
+ return this[i].localName;
2239
+ },
2240
+ getLocator: function(i) {
2241
+ return this[i].locator;
2242
+ },
2243
+ getQName: function(i) {
2244
+ return this[i].qName;
2245
+ },
2246
+ getURI: function(i) {
2247
+ return this[i].uri;
2248
+ },
2249
+ getValue: function(i) {
2250
+ return this[i].value;
2251
+ }
2252
+ // ,getIndex:function(uri, localName)){
2253
+ // if(localName){
2254
+ //
2255
+ // }else{
2256
+ // var qName = uri
2257
+ // }
2258
+ // },
2259
+ // getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
2260
+ // getType:function(uri,localName){}
2261
+ // getType:function(i){},
2262
+ };
2263
+ function split(source, start) {
2264
+ var match;
2265
+ var buf = [];
2266
+ var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
2267
+ reg.lastIndex = start;
2268
+ reg.exec(source);
2269
+ while (match = reg.exec(source)) {
2270
+ buf.push(match);
2271
+ if (match[1])
2272
+ return buf;
2273
+ }
2274
+ }
2275
+ sax$1.XMLReader = XMLReader$1;
2276
+ sax$1.ParseError = ParseError$1;
2277
+ var conventions = conventions$2;
2278
+ var dom = dom$1;
2279
+ var entities = entities$1;
2280
+ var sax = sax$1;
2281
+ var DOMImplementation = dom.DOMImplementation;
2282
+ var NAMESPACE = conventions.NAMESPACE;
2283
+ var ParseError = sax.ParseError;
2284
+ var XMLReader = sax.XMLReader;
2285
+ function normalizeLineEndings(input) {
2286
+ return input.replace(/\r[\n\u0085]/g, "\n").replace(/[\r\u0085\u2028]/g, "\n");
2287
+ }
2288
+ function DOMParser$1(options) {
2289
+ this.options = options || { locator: {} };
2290
+ }
2291
+ DOMParser$1.prototype.parseFromString = function(source, mimeType) {
2292
+ var options = this.options;
2293
+ var sax2 = new XMLReader();
2294
+ var domBuilder = options.domBuilder || new DOMHandler();
2295
+ var errorHandler = options.errorHandler;
2296
+ var locator = options.locator;
2297
+ var defaultNSMap = options.xmlns || {};
2298
+ var isHTML = /\/x?html?$/.test(mimeType);
2299
+ var entityMap = isHTML ? entities.HTML_ENTITIES : entities.XML_ENTITIES;
2300
+ if (locator) {
2301
+ domBuilder.setDocumentLocator(locator);
2302
+ }
2303
+ sax2.errorHandler = buildErrorHandler(errorHandler, domBuilder, locator);
2304
+ sax2.domBuilder = options.domBuilder || domBuilder;
2305
+ if (isHTML) {
2306
+ defaultNSMap[""] = NAMESPACE.HTML;
2307
+ }
2308
+ defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;
2309
+ var normalize = options.normalizeLineEndings || normalizeLineEndings;
2310
+ if (source && typeof source === "string") {
2311
+ sax2.parse(
2312
+ normalize(source),
2313
+ defaultNSMap,
2314
+ entityMap
2315
+ );
2316
+ } else {
2317
+ sax2.errorHandler.error("invalid doc source");
2318
+ }
2319
+ return domBuilder.doc;
2320
+ };
2321
+ function buildErrorHandler(errorImpl, domBuilder, locator) {
2322
+ if (!errorImpl) {
2323
+ if (domBuilder instanceof DOMHandler) {
2324
+ return domBuilder;
2325
+ }
2326
+ errorImpl = domBuilder;
2327
+ }
2328
+ var errorHandler = {};
2329
+ var isCallback = errorImpl instanceof Function;
2330
+ locator = locator || {};
2331
+ function build(key) {
2332
+ var fn = errorImpl[key];
2333
+ if (!fn && isCallback) {
2334
+ fn = errorImpl.length == 2 ? function(msg) {
2335
+ errorImpl(key, msg);
2336
+ } : errorImpl;
2337
+ }
2338
+ errorHandler[key] = fn && function(msg) {
2339
+ fn("[xmldom " + key + "] " + msg + _locator(locator));
2340
+ } || function() {
2341
+ };
2342
+ }
2343
+ build("warning");
2344
+ build("error");
2345
+ build("fatalError");
2346
+ return errorHandler;
2347
+ }
2348
+ function DOMHandler() {
2349
+ this.cdata = false;
2350
+ }
2351
+ function position(locator, node) {
2352
+ node.lineNumber = locator.lineNumber;
2353
+ node.columnNumber = locator.columnNumber;
2354
+ }
2355
+ DOMHandler.prototype = {
2356
+ startDocument: function() {
2357
+ this.doc = new DOMImplementation().createDocument(null, null, null);
2358
+ if (this.locator) {
2359
+ this.doc.documentURI = this.locator.systemId;
2360
+ }
2361
+ },
2362
+ startElement: function(namespaceURI, localName, qName, attrs) {
2363
+ var doc = this.doc;
2364
+ var el = doc.createElementNS(namespaceURI, qName || localName);
2365
+ var len = attrs.length;
2366
+ appendElement(this, el);
2367
+ this.currentElement = el;
2368
+ this.locator && position(this.locator, el);
2369
+ for (var i = 0; i < len; i++) {
2370
+ var namespaceURI = attrs.getURI(i);
2371
+ var value = attrs.getValue(i);
2372
+ var qName = attrs.getQName(i);
2373
+ var attr = doc.createAttributeNS(namespaceURI, qName);
2374
+ this.locator && position(attrs.getLocator(i), attr);
2375
+ attr.value = attr.nodeValue = value;
2376
+ el.setAttributeNode(attr);
2377
+ }
2378
+ },
2379
+ endElement: function(namespaceURI, localName, qName) {
2380
+ var current = this.currentElement;
2381
+ current.tagName;
2382
+ this.currentElement = current.parentNode;
2383
+ },
2384
+ startPrefixMapping: function(prefix, uri) {
2385
+ },
2386
+ endPrefixMapping: function(prefix) {
2387
+ },
2388
+ processingInstruction: function(target, data) {
2389
+ var ins = this.doc.createProcessingInstruction(target, data);
2390
+ this.locator && position(this.locator, ins);
2391
+ appendElement(this, ins);
2392
+ },
2393
+ ignorableWhitespace: function(ch, start, length) {
2394
+ },
2395
+ characters: function(chars, start, length) {
2396
+ chars = _toString.apply(this, arguments);
2397
+ if (chars) {
2398
+ if (this.cdata) {
2399
+ var charNode = this.doc.createCDATASection(chars);
2400
+ } else {
2401
+ var charNode = this.doc.createTextNode(chars);
2402
+ }
2403
+ if (this.currentElement) {
2404
+ this.currentElement.appendChild(charNode);
2405
+ } else if (/^\s*$/.test(chars)) {
2406
+ this.doc.appendChild(charNode);
2407
+ }
2408
+ this.locator && position(this.locator, charNode);
2409
+ }
2410
+ },
2411
+ skippedEntity: function(name) {
2412
+ },
2413
+ endDocument: function() {
2414
+ this.doc.normalize();
2415
+ },
2416
+ setDocumentLocator: function(locator) {
2417
+ if (this.locator = locator) {
2418
+ locator.lineNumber = 0;
2419
+ }
2420
+ },
2421
+ //LexicalHandler
2422
+ comment: function(chars, start, length) {
2423
+ chars = _toString.apply(this, arguments);
2424
+ var comm = this.doc.createComment(chars);
2425
+ this.locator && position(this.locator, comm);
2426
+ appendElement(this, comm);
2427
+ },
2428
+ startCDATA: function() {
2429
+ this.cdata = true;
2430
+ },
2431
+ endCDATA: function() {
2432
+ this.cdata = false;
2433
+ },
2434
+ startDTD: function(name, publicId, systemId) {
2435
+ var impl = this.doc.implementation;
2436
+ if (impl && impl.createDocumentType) {
2437
+ var dt = impl.createDocumentType(name, publicId, systemId);
2438
+ this.locator && position(this.locator, dt);
2439
+ appendElement(this, dt);
2440
+ this.doc.doctype = dt;
2441
+ }
2442
+ },
2443
+ /**
2444
+ * @see org.xml.sax.ErrorHandler
2445
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
2446
+ */
2447
+ warning: function(error) {
2448
+ console.warn("[xmldom warning] " + error, _locator(this.locator));
2449
+ },
2450
+ error: function(error) {
2451
+ console.error("[xmldom error] " + error, _locator(this.locator));
2452
+ },
2453
+ fatalError: function(error) {
2454
+ throw new ParseError(error, this.locator);
2455
+ }
2456
+ };
2457
+ function _locator(l) {
2458
+ if (l) {
2459
+ return "\n@" + (l.systemId || "") + "#[line:" + l.lineNumber + ",col:" + l.columnNumber + "]";
2460
+ }
2461
+ }
2462
+ function _toString(chars, start, length) {
2463
+ if (typeof chars == "string") {
2464
+ return chars.substr(start, length);
2465
+ } else {
2466
+ if (chars.length >= start + length || start) {
2467
+ return new java.lang.String(chars, start, length) + "";
2468
+ }
2469
+ return chars;
2470
+ }
2471
+ }
2472
+ "endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g, function(key) {
2473
+ DOMHandler.prototype[key] = function() {
2474
+ return null;
2475
+ };
2476
+ });
2477
+ function appendElement(hander, node) {
2478
+ if (!hander.currentElement) {
2479
+ hander.doc.appendChild(node);
2480
+ } else {
2481
+ hander.currentElement.appendChild(node);
2482
+ }
2483
+ }
2484
+ domParser.__DOMHandler = DOMHandler;
2485
+ domParser.normalizeLineEndings = normalizeLineEndings;
2486
+ domParser.DOMParser = DOMParser$1;
2487
+ var DOMParser = domParser.DOMParser;
2488
+ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2489
+ __proto__: null,
2490
+ DOMParser
2491
+ }, Symbol.toStringTag, { value: "Module" }));
2492
+ export {
2493
+ index as i
2494
+ };