solid-ui 2.4.13 → 2.4.14-6a9e81a9
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/lib/acl/access-groups.d.ts +1 -1
- package/lib/acl/access-groups.d.ts.map +1 -1
- package/lib/acl/access-groups.js.map +1 -1
- package/lib/acl/acl.d.ts +1 -1
- package/lib/acl/acl.d.ts.map +1 -1
- package/lib/acl/acl.js.map +1 -1
- package/lib/footer/index.d.ts +20 -0
- package/lib/footer/index.d.ts.map +1 -0
- package/lib/footer/index.js +147 -0
- package/lib/footer/index.js.map +1 -0
- package/lib/footer/styleMap.d.ts +8 -0
- package/lib/footer/styleMap.d.ts.map +1 -0
- package/lib/footer/styleMap.js +15 -0
- package/lib/footer/styleMap.js.map +1 -0
- package/lib/header/index.d.ts +11 -8
- package/lib/header/index.d.ts.map +1 -1
- package/lib/header/index.js +78 -66
- package/lib/header/index.js.map +1 -1
- package/lib/header/styleMap.d.ts +0 -2
- package/lib/header/styleMap.d.ts.map +1 -1
- package/lib/header/styleMap.js +1 -5
- package/lib/header/styleMap.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +10 -1
- package/lib/index.js.map +1 -1
- package/lib/{header/headerHelpers.d.ts → utils/headerFooterHelpers.d.ts} +11 -3
- package/lib/utils/headerFooterHelpers.d.ts.map +1 -0
- package/lib/utils/headerFooterHelpers.js +189 -0
- package/lib/utils/headerFooterHelpers.js.map +1 -0
- package/lib/versionInfo.js +3 -3
- package/lib/versionInfo.js.map +1 -1
- package/lib/webpack-bundle.js +3456 -174
- package/lib/webpack-bundle.js.map +1 -1
- package/package.json +6 -5
- package/lib/header/headerHelpers.d.ts.map +0 -1
- package/lib/header/headerHelpers.js +0 -96
- package/lib/header/headerHelpers.js.map +0 -1
package/lib/webpack-bundle.js
CHANGED
|
@@ -8465,30 +8465,10 @@ function trace() {
|
|
|
8465
8465
|
|
|
8466
8466
|
/***/ }),
|
|
8467
8467
|
|
|
8468
|
-
/***/ "./lib/
|
|
8469
|
-
|
|
8470
|
-
!*** ./lib/
|
|
8471
|
-
|
|
8472
|
-
/*! no static exports found */
|
|
8473
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
8474
|
-
|
|
8475
|
-
"use strict";
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8479
|
-
value: true
|
|
8480
|
-
});
|
|
8481
|
-
exports.emptyProfile = void 0;
|
|
8482
|
-
var emptyProfile = "\n<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"26\" height=\"26\" viewBox=\"0 0 26 26\" fill=\"none\">\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M13 25C19.6274 25 25 19.6274 25 13C25 6.37258 19.6274 1 13 1C6.37258 1 1 6.37258 1 13C1 19.6274 6.37258 25 13 25Z\" fill=\"#D8D8D8\" stroke=\"#8B8B8B\"/>\n <mask id=\"mask0\" mask-type=\"alpha\" maskUnits=\"userSpaceOnUse\" x=\"0\" y=\"0\" width=\"26\" height=\"26\">\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M13 25C19.6274 25 25 19.6274 25 13C25 6.37258 19.6274 1 13 1C6.37258 1 1 6.37258 1 13C1 19.6274 6.37258 25 13 25Z\" fill=\"white\" stroke=\"white\"/>\n </mask>\n <g mask=\"url(#mask0)\">\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M17.0468 10.4586C17.0468 14.4979 15.4281 16.9214 12.9999 16.9214C10.5718 16.9214 8.95298 14.4979 8.95298 10.4586C8.95298 6.41931 12.9999 6.41931 12.9999 6.41931C12.9999 6.41931 17.0468 6.41931 17.0468 10.4586ZM4.09668 23.3842C6.52483 17.7293 12.9999 17.7293 12.9999 17.7293C12.9999 17.7293 19.475 17.7293 21.9031 23.3842C21.9031 23.3842 17.8481 25 12.9999 25C8.15169 25 4.09668 23.3842 4.09668 23.3842Z\" fill=\"#8B8B8B\"/>\n </g>\n</svg>";
|
|
8483
|
-
exports.emptyProfile = emptyProfile;
|
|
8484
|
-
//# sourceMappingURL=empty-profile.js.map
|
|
8485
|
-
|
|
8486
|
-
/***/ }),
|
|
8487
|
-
|
|
8488
|
-
/***/ "./lib/header/headerHelpers.js":
|
|
8489
|
-
/*!*************************************!*\
|
|
8490
|
-
!*** ./lib/header/headerHelpers.js ***!
|
|
8491
|
-
\*************************************/
|
|
8468
|
+
/***/ "./lib/footer/index.js":
|
|
8469
|
+
/*!*****************************!*\
|
|
8470
|
+
!*** ./lib/footer/index.js ***!
|
|
8471
|
+
\*****************************/
|
|
8492
8472
|
/*! no static exports found */
|
|
8493
8473
|
/***/ (function(module, exports, __webpack_require__) {
|
|
8494
8474
|
|
|
@@ -8500,95 +8480,192 @@ var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/inte
|
|
|
8500
8480
|
Object.defineProperty(exports, "__esModule", {
|
|
8501
8481
|
value: true
|
|
8502
8482
|
});
|
|
8503
|
-
exports.
|
|
8504
|
-
exports.
|
|
8505
|
-
exports.
|
|
8483
|
+
exports.createControllerInfoBlock = createControllerInfoBlock;
|
|
8484
|
+
exports.initFooter = initFooter;
|
|
8485
|
+
exports.rebuildFooter = rebuildFooter;
|
|
8506
8486
|
|
|
8507
|
-
var
|
|
8487
|
+
var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
|
|
8508
8488
|
|
|
8509
|
-
var
|
|
8489
|
+
var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
|
|
8510
8490
|
|
|
8511
|
-
var
|
|
8491
|
+
var _authn = __webpack_require__(/*! ../authn/authn */ "./lib/authn/authn.js");
|
|
8512
8492
|
|
|
8513
|
-
var
|
|
8493
|
+
var _headerFooterHelpers = __webpack_require__(/*! ../utils/headerFooterHelpers */ "./lib/utils/headerFooterHelpers.js");
|
|
8514
8494
|
|
|
8515
8495
|
/*
|
|
8516
|
-
|
|
8496
|
+
This file was copied from mashlib/src/global/footer.ts file. It is modified to
|
|
8497
|
+
work in solid-ui by adjusting where imported functions are found.
|
|
8517
8498
|
*/
|
|
8499
|
+
var DEFAULT_SOLID_PROJECT_URL = 'https://solidproject.org';
|
|
8500
|
+
var DEFAULT_SOLID_PROJECT_NAME = 'solidproject.org';
|
|
8501
|
+
/*
|
|
8502
|
+
FooterOptions allow for customizing the link and name of the link part of the footer.
|
|
8503
|
+
*/
|
|
8518
8504
|
|
|
8519
8505
|
/**
|
|
8520
|
-
*
|
|
8506
|
+
* Initialize footer component, the footer object returned depends on whether the user is authenticated.
|
|
8507
|
+
* @param store the data store
|
|
8508
|
+
* @returns the footer
|
|
8521
8509
|
*/
|
|
8522
|
-
function
|
|
8523
|
-
return
|
|
8510
|
+
function initFooter(_x, _x2) {
|
|
8511
|
+
return _initFooter.apply(this, arguments);
|
|
8524
8512
|
}
|
|
8525
8513
|
/**
|
|
8526
8514
|
* @ignore exporting this only for the unit test
|
|
8527
8515
|
*/
|
|
8528
8516
|
|
|
8529
8517
|
|
|
8530
|
-
function
|
|
8531
|
-
|
|
8532
|
-
var
|
|
8518
|
+
function _initFooter() {
|
|
8519
|
+
_initFooter = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(store, options) {
|
|
8520
|
+
var footer, pod, podOwner;
|
|
8521
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
8522
|
+
while (1) {
|
|
8523
|
+
switch (_context2.prev = _context2.next) {
|
|
8524
|
+
case 0:
|
|
8525
|
+
footer = document.getElementById('PageFooter');
|
|
8533
8526
|
|
|
8534
|
-
|
|
8535
|
-
|
|
8527
|
+
if (footer) {
|
|
8528
|
+
_context2.next = 3;
|
|
8529
|
+
break;
|
|
8530
|
+
}
|
|
8536
8531
|
|
|
8537
|
-
|
|
8538
|
-
|
|
8532
|
+
return _context2.abrupt("return");
|
|
8533
|
+
|
|
8534
|
+
case 3:
|
|
8535
|
+
pod = (0, _headerFooterHelpers.getPod)();
|
|
8536
|
+
_context2.next = 6;
|
|
8537
|
+
return (0, _headerFooterHelpers.getPodOwner)(pod, store);
|
|
8538
|
+
|
|
8539
|
+
case 6:
|
|
8540
|
+
podOwner = _context2.sent;
|
|
8541
|
+
rebuildFooter(footer, store, pod, podOwner, options)();
|
|
8542
|
+
|
|
8543
|
+
_authn.authSession.onLogin(rebuildFooter(footer, store, pod, podOwner, options));
|
|
8544
|
+
|
|
8545
|
+
_authn.authSession.onLogout(rebuildFooter(footer, store, pod, podOwner, options));
|
|
8546
|
+
|
|
8547
|
+
case 10:
|
|
8548
|
+
case "end":
|
|
8549
|
+
return _context2.stop();
|
|
8550
|
+
}
|
|
8551
|
+
}
|
|
8552
|
+
}, _callee2);
|
|
8553
|
+
}));
|
|
8554
|
+
return _initFooter.apply(this, arguments);
|
|
8539
8555
|
}
|
|
8540
|
-
/**
|
|
8541
|
-
* @ignore exporting this only for the unit test
|
|
8542
|
-
*/
|
|
8543
8556
|
|
|
8557
|
+
function rebuildFooter(footer, store, pod, podOwner, options) {
|
|
8558
|
+
return /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
8559
|
+
var user;
|
|
8560
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
8561
|
+
while (1) {
|
|
8562
|
+
switch (_context.prev = _context.next) {
|
|
8563
|
+
case 0:
|
|
8564
|
+
user = (0, _authn.currentUser)();
|
|
8565
|
+
footer.innerHTML = '';
|
|
8566
|
+
_context.t0 = footer;
|
|
8567
|
+
_context.next = 5;
|
|
8568
|
+
return createControllerInfoBlock(store, user, pod, podOwner, options);
|
|
8569
|
+
|
|
8570
|
+
case 5:
|
|
8571
|
+
_context.t1 = _context.sent;
|
|
8544
8572
|
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8573
|
+
_context.t0.appendChild.call(_context.t0, _context.t1);
|
|
8574
|
+
|
|
8575
|
+
case 7:
|
|
8576
|
+
case "end":
|
|
8577
|
+
return _context.stop();
|
|
8578
|
+
}
|
|
8579
|
+
}
|
|
8580
|
+
}, _callee);
|
|
8581
|
+
}));
|
|
8548
8582
|
}
|
|
8549
8583
|
/**
|
|
8550
8584
|
* @ignore exporting this only for the unit test
|
|
8551
8585
|
*/
|
|
8552
8586
|
|
|
8553
8587
|
|
|
8554
|
-
function
|
|
8555
|
-
var
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8588
|
+
function createControllerInfoBlock(store, user, pod, podOwner, options) {
|
|
8589
|
+
var profileLinkContainer = document.createElement('div');
|
|
8590
|
+
|
|
8591
|
+
if (!pod || !podOwner || user && user.equals(podOwner)) {
|
|
8592
|
+
return profileLinkContainer;
|
|
8593
|
+
}
|
|
8594
|
+
|
|
8595
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(profileLinkContainer, ['footer-pod-info', 'footer'], 'footer');
|
|
8596
|
+
var podLinkPre = document.createElement('span');
|
|
8597
|
+
podLinkPre.innerText = "You're visiting ";
|
|
8598
|
+
var podLink = document.createElement('a');
|
|
8599
|
+
podLink.href = pod.uri;
|
|
8600
|
+
podLink.innerText = 'the Pod';
|
|
8601
|
+
var profileLinkPre = document.createElement('span');
|
|
8602
|
+
profileLinkPre.innerText = ' controlled by ';
|
|
8603
|
+
var profileLink = document.createElement('a');
|
|
8604
|
+
profileLink.href = podOwner.uri;
|
|
8605
|
+
profileLink.innerText = (0, _headerFooterHelpers.getName)(store, podOwner);
|
|
8606
|
+
var solidProjectLinkPre = document.createElement('span');
|
|
8607
|
+
solidProjectLinkPre.innerText = '. For more info, check out ';
|
|
8608
|
+
var solidProjectLink = document.createElement('a');
|
|
8609
|
+
solidProjectLink.href = options && options.solidProjectUrl ? options.solidProjectUrl : DEFAULT_SOLID_PROJECT_URL;
|
|
8610
|
+
solidProjectLink.innerText = options && options.solidProjectName ? options.solidProjectName : DEFAULT_SOLID_PROJECT_NAME;
|
|
8611
|
+
var solidProjectLinkPost = document.createElement('span');
|
|
8612
|
+
solidProjectLinkPost.innerText = '.';
|
|
8613
|
+
profileLinkContainer.appendChild(podLinkPre);
|
|
8614
|
+
profileLinkContainer.appendChild(podLink);
|
|
8615
|
+
profileLinkContainer.appendChild(profileLinkPre);
|
|
8616
|
+
profileLinkContainer.appendChild(profileLink);
|
|
8617
|
+
profileLinkContainer.appendChild(solidProjectLinkPre);
|
|
8618
|
+
profileLinkContainer.appendChild(solidProjectLink);
|
|
8619
|
+
profileLinkContainer.appendChild(solidProjectLinkPost);
|
|
8620
|
+
return profileLinkContainer;
|
|
8621
|
+
}
|
|
8622
|
+
//# sourceMappingURL=index.js.map
|
|
8559
8623
|
|
|
8560
|
-
|
|
8561
|
-
previous = !options.leading ? 0 : Date.now();
|
|
8562
|
-
timeout = null;
|
|
8563
|
-
result = func.apply(context, args);
|
|
8564
|
-
if (!timeout) context = args = null;
|
|
8565
|
-
};
|
|
8624
|
+
/***/ }),
|
|
8566
8625
|
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
|
|
8570
|
-
|
|
8626
|
+
/***/ "./lib/footer/styleMap.js":
|
|
8627
|
+
/*!********************************!*\
|
|
8628
|
+
!*** ./lib/footer/styleMap.js ***!
|
|
8629
|
+
\********************************/
|
|
8630
|
+
/*! no static exports found */
|
|
8631
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
8571
8632
|
|
|
8572
|
-
|
|
8573
|
-
args = arguments;
|
|
8633
|
+
"use strict";
|
|
8574
8634
|
|
|
8575
|
-
if (remaining <= 0 || remaining > wait) {
|
|
8576
|
-
if (timeout) {
|
|
8577
|
-
clearTimeout(timeout);
|
|
8578
|
-
timeout = null;
|
|
8579
|
-
}
|
|
8580
8635
|
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
|
|
8636
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8637
|
+
value: true
|
|
8638
|
+
});
|
|
8639
|
+
exports.styleMap = void 0;
|
|
8640
|
+
var styleMap = {
|
|
8641
|
+
footer: {
|
|
8642
|
+
borderTop: 'solid 1px $divider-color',
|
|
8643
|
+
fontSize: '0.9em',
|
|
8644
|
+
padding: '0.5em 1.5em'
|
|
8645
|
+
}
|
|
8646
|
+
};
|
|
8647
|
+
exports.styleMap = styleMap;
|
|
8648
|
+
//# sourceMappingURL=styleMap.js.map
|
|
8587
8649
|
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8650
|
+
/***/ }),
|
|
8651
|
+
|
|
8652
|
+
/***/ "./lib/header/empty-profile.js":
|
|
8653
|
+
/*!*************************************!*\
|
|
8654
|
+
!*** ./lib/header/empty-profile.js ***!
|
|
8655
|
+
\*************************************/
|
|
8656
|
+
/*! no static exports found */
|
|
8657
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
8658
|
+
|
|
8659
|
+
"use strict";
|
|
8660
|
+
|
|
8661
|
+
|
|
8662
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8663
|
+
value: true
|
|
8664
|
+
});
|
|
8665
|
+
exports.emptyProfile = void 0;
|
|
8666
|
+
var emptyProfile = "\n<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"26\" height=\"26\" viewBox=\"0 0 26 26\" fill=\"none\">\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M13 25C19.6274 25 25 19.6274 25 13C25 6.37258 19.6274 1 13 1C6.37258 1 1 6.37258 1 13C1 19.6274 6.37258 25 13 25Z\" fill=\"#D8D8D8\" stroke=\"#8B8B8B\"/>\n <mask id=\"mask0\" mask-type=\"alpha\" maskUnits=\"userSpaceOnUse\" x=\"0\" y=\"0\" width=\"26\" height=\"26\">\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M13 25C19.6274 25 25 19.6274 25 13C25 6.37258 19.6274 1 13 1C6.37258 1 1 6.37258 1 13C1 19.6274 6.37258 25 13 25Z\" fill=\"white\" stroke=\"white\"/>\n </mask>\n <g mask=\"url(#mask0)\">\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M17.0468 10.4586C17.0468 14.4979 15.4281 16.9214 12.9999 16.9214C10.5718 16.9214 8.95298 14.4979 8.95298 10.4586C8.95298 6.41931 12.9999 6.41931 12.9999 6.41931C12.9999 6.41931 17.0468 6.41931 17.0468 10.4586ZM4.09668 23.3842C6.52483 17.7293 12.9999 17.7293 12.9999 17.7293C12.9999 17.7293 19.475 17.7293 21.9031 23.3842C21.9031 23.3842 17.8481 25 12.9999 25C8.15169 25 4.09668 23.3842 4.09668 23.3842Z\" fill=\"#8B8B8B\"/>\n </g>\n</svg>";
|
|
8667
|
+
exports.emptyProfile = emptyProfile;
|
|
8668
|
+
//# sourceMappingURL=empty-profile.js.map
|
|
8592
8669
|
|
|
8593
8670
|
/***/ }),
|
|
8594
8671
|
|
|
@@ -8624,7 +8701,7 @@ var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime
|
|
|
8624
8701
|
|
|
8625
8702
|
var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
|
|
8626
8703
|
|
|
8627
|
-
var
|
|
8704
|
+
var _iconBase = __webpack_require__(/*! ../iconBase */ "./lib/iconBase.js");
|
|
8628
8705
|
|
|
8629
8706
|
var _authn = __webpack_require__(/*! ../authn/authn */ "./lib/authn/authn.js");
|
|
8630
8707
|
|
|
@@ -8632,7 +8709,7 @@ var widgets = _interopRequireWildcard(__webpack_require__(/*! ../widgets */ "./l
|
|
|
8632
8709
|
|
|
8633
8710
|
var _emptyProfile = __webpack_require__(/*! ./empty-profile */ "./lib/header/empty-profile.js");
|
|
8634
8711
|
|
|
8635
|
-
var
|
|
8712
|
+
var _headerFooterHelpers = __webpack_require__(/*! ../utils/headerFooterHelpers */ "./lib/utils/headerFooterHelpers.js");
|
|
8636
8713
|
|
|
8637
8714
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
8638
8715
|
|
|
@@ -8645,13 +8722,20 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
8645
8722
|
work in solid-ui by adjusting where imported functions are found.
|
|
8646
8723
|
*/
|
|
8647
8724
|
|
|
8725
|
+
/**
|
|
8726
|
+
* menu icons
|
|
8727
|
+
*/
|
|
8728
|
+
var DEFAULT_HELP_MENU_ICON = _iconBase.icons.iconBase + 'noun_help.svg';
|
|
8729
|
+
var DEFAUL_SOLID_ICON_URL = 'https://solidproject.org/assets/img/solid-emblem.svg';
|
|
8730
|
+
|
|
8648
8731
|
/**
|
|
8649
8732
|
* Initialize header component, the header object returned depends on whether the user is authenticated.
|
|
8650
8733
|
* @param store the data store
|
|
8651
|
-
* @param
|
|
8734
|
+
* @param userMenuList a list of menu items when the user is logged in
|
|
8735
|
+
* @param options allow the header to be customized with a personalized logo, help icon and a help menu list of links or buttons.
|
|
8652
8736
|
* @returns a header for an authenticated user with menu items given or a login screen
|
|
8653
8737
|
*/
|
|
8654
|
-
function initHeader(_x, _x2) {
|
|
8738
|
+
function initHeader(_x, _x2, _x3) {
|
|
8655
8739
|
return _initHeader.apply(this, arguments);
|
|
8656
8740
|
}
|
|
8657
8741
|
/**
|
|
@@ -8660,7 +8744,7 @@ function initHeader(_x, _x2) {
|
|
|
8660
8744
|
|
|
8661
8745
|
|
|
8662
8746
|
function _initHeader() {
|
|
8663
|
-
_initHeader = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(store, options) {
|
|
8747
|
+
_initHeader = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(store, userMenuList, options) {
|
|
8664
8748
|
var header, pod;
|
|
8665
8749
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
8666
8750
|
while (1) {
|
|
@@ -8676,12 +8760,12 @@ function _initHeader() {
|
|
|
8676
8760
|
return _context2.abrupt("return");
|
|
8677
8761
|
|
|
8678
8762
|
case 3:
|
|
8679
|
-
pod = (0,
|
|
8680
|
-
rebuildHeader(header, store, pod, options)();
|
|
8763
|
+
pod = (0, _headerFooterHelpers.getPod)();
|
|
8764
|
+
rebuildHeader(header, store, pod, userMenuList, options)();
|
|
8681
8765
|
|
|
8682
|
-
_authn.authSession.onLogout(rebuildHeader(header, store, pod, options));
|
|
8766
|
+
_authn.authSession.onLogout(rebuildHeader(header, store, pod, userMenuList, options));
|
|
8683
8767
|
|
|
8684
|
-
_authn.authSession.onLogin(rebuildHeader(header, store, pod, options));
|
|
8768
|
+
_authn.authSession.onLogin(rebuildHeader(header, store, pod, userMenuList, options));
|
|
8685
8769
|
|
|
8686
8770
|
case 7:
|
|
8687
8771
|
case "end":
|
|
@@ -8693,7 +8777,7 @@ function _initHeader() {
|
|
|
8693
8777
|
return _initHeader.apply(this, arguments);
|
|
8694
8778
|
}
|
|
8695
8779
|
|
|
8696
|
-
function rebuildHeader(header, store, pod, options) {
|
|
8780
|
+
function rebuildHeader(header, store, pod, userMenuList, options) {
|
|
8697
8781
|
return /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
8698
8782
|
var user;
|
|
8699
8783
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
@@ -8704,7 +8788,7 @@ function rebuildHeader(header, store, pod, options) {
|
|
|
8704
8788
|
header.innerHTML = '';
|
|
8705
8789
|
_context.t0 = header;
|
|
8706
8790
|
_context.next = 5;
|
|
8707
|
-
return createBanner(store, pod, user, options);
|
|
8791
|
+
return createBanner(store, pod, user, userMenuList, options);
|
|
8708
8792
|
|
|
8709
8793
|
case 5:
|
|
8710
8794
|
_context.t1 = _context.sent;
|
|
@@ -8724,7 +8808,7 @@ function rebuildHeader(header, store, pod, options) {
|
|
|
8724
8808
|
*/
|
|
8725
8809
|
|
|
8726
8810
|
|
|
8727
|
-
function createBanner(
|
|
8811
|
+
function createBanner(_x4, _x5, _x6, _x7, _x8) {
|
|
8728
8812
|
return _createBanner.apply(this, arguments);
|
|
8729
8813
|
}
|
|
8730
8814
|
/**
|
|
@@ -8733,22 +8817,22 @@ function createBanner(_x3, _x4, _x5, _x6) {
|
|
|
8733
8817
|
|
|
8734
8818
|
|
|
8735
8819
|
function _createBanner() {
|
|
8736
|
-
_createBanner = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(store, pod, user, options) {
|
|
8737
|
-
var podLink, image, userMenu,
|
|
8820
|
+
_createBanner = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(store, pod, user, userMenuList, options) {
|
|
8821
|
+
var podLink, image, userMenu, banner, leftSideOfHeader, helpMenu;
|
|
8738
8822
|
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
8739
8823
|
while (1) {
|
|
8740
8824
|
switch (_context3.prev = _context3.next) {
|
|
8741
8825
|
case 0:
|
|
8742
8826
|
podLink = document.createElement('a');
|
|
8743
8827
|
podLink.href = pod.uri;
|
|
8744
|
-
(0,
|
|
8828
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(podLink, ['header-banner__link']);
|
|
8745
8829
|
image = document.createElement('img');
|
|
8746
8830
|
|
|
8747
8831
|
if (options) {
|
|
8748
|
-
image.src = options.logo ? options.logo :
|
|
8832
|
+
image.src = options.logo ? options.logo : DEFAUL_SOLID_ICON_URL;
|
|
8749
8833
|
}
|
|
8750
8834
|
|
|
8751
|
-
(0,
|
|
8835
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(image, ['header-banner__icon']);
|
|
8752
8836
|
podLink.appendChild(image);
|
|
8753
8837
|
|
|
8754
8838
|
if (!user) {
|
|
@@ -8757,7 +8841,7 @@ function _createBanner() {
|
|
|
8757
8841
|
}
|
|
8758
8842
|
|
|
8759
8843
|
_context3.next = 10;
|
|
8760
|
-
return createUserMenu(store, user,
|
|
8844
|
+
return createUserMenu(store, user, userMenuList);
|
|
8761
8845
|
|
|
8762
8846
|
case 10:
|
|
8763
8847
|
_context3.t0 = _context3.sent;
|
|
@@ -8769,18 +8853,22 @@ function _createBanner() {
|
|
|
8769
8853
|
|
|
8770
8854
|
case 14:
|
|
8771
8855
|
userMenu = _context3.t0;
|
|
8772
|
-
helpMenu = createHelpMenu();
|
|
8773
8856
|
banner = document.createElement('div');
|
|
8774
|
-
(0,
|
|
8857
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(banner, ['header-banner']);
|
|
8775
8858
|
banner.appendChild(podLink);
|
|
8776
8859
|
leftSideOfHeader = document.createElement('div');
|
|
8777
|
-
(0,
|
|
8860
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(leftSideOfHeader, ['header-banner__right-menu']);
|
|
8778
8861
|
leftSideOfHeader.appendChild(userMenu);
|
|
8779
|
-
|
|
8862
|
+
|
|
8863
|
+
if (options && options.helpMenuList) {
|
|
8864
|
+
helpMenu = createHelpMenu(options, options.helpMenuList);
|
|
8865
|
+
leftSideOfHeader.appendChild(helpMenu);
|
|
8866
|
+
}
|
|
8867
|
+
|
|
8780
8868
|
banner.appendChild(leftSideOfHeader);
|
|
8781
8869
|
return _context3.abrupt("return", banner);
|
|
8782
8870
|
|
|
8783
|
-
case
|
|
8871
|
+
case 24:
|
|
8784
8872
|
case "end":
|
|
8785
8873
|
return _context3.stop();
|
|
8786
8874
|
}
|
|
@@ -8790,29 +8878,36 @@ function _createBanner() {
|
|
|
8790
8878
|
return _createBanner.apply(this, arguments);
|
|
8791
8879
|
}
|
|
8792
8880
|
|
|
8793
|
-
function createHelpMenu() {
|
|
8881
|
+
function createHelpMenu(options, helpMenuItems) {
|
|
8882
|
+
if (!helpMenuItems) return;
|
|
8794
8883
|
var helpMenuList = document.createElement('ul');
|
|
8795
|
-
(0,
|
|
8796
|
-
|
|
8797
|
-
|
|
8884
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(helpMenuList, ['header-user-menu__list']);
|
|
8885
|
+
helpMenuItems.forEach(function (menuItem) {
|
|
8886
|
+
var menuItemType = menuItem.url ? 'url' : 'onclick';
|
|
8887
|
+
|
|
8888
|
+
if (menuItemType === 'url') {
|
|
8889
|
+
helpMenuList.appendChild(createUserMenuItem(createUserMenuLink(menuItem.label, menuItem.url, menuItem.target)));
|
|
8890
|
+
} else {
|
|
8891
|
+
helpMenuList.appendChild(createUserMenuItem(createUserMenuButton(menuItem.label, menuItem.onclick)));
|
|
8892
|
+
}
|
|
8893
|
+
});
|
|
8798
8894
|
var helpMenu = document.createElement('nav');
|
|
8799
|
-
(0,
|
|
8895
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(helpMenu, ['header-user-menu__navigation-menu']);
|
|
8800
8896
|
helpMenu.setAttribute('aria-hidden', 'true');
|
|
8801
8897
|
helpMenu.appendChild(helpMenuList);
|
|
8802
|
-
var helpIcon = _.icons.iconBase + 'noun_144.svg';
|
|
8803
8898
|
var helpMenuContainer = document.createElement('div');
|
|
8804
|
-
(0,
|
|
8805
|
-
(0,
|
|
8899
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(helpMenuContainer, ['header-banner__user-menu']);
|
|
8900
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(helpMenuContainer, ['header-user-menu']);
|
|
8806
8901
|
helpMenuContainer.appendChild(helpMenu);
|
|
8807
8902
|
var helpMenuTrigger = document.createElement('button');
|
|
8808
|
-
(0,
|
|
8903
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(helpMenuTrigger, ['header-user-menu__trigger']);
|
|
8809
8904
|
helpMenuTrigger.type = 'button';
|
|
8810
8905
|
var helpMenuIcon = document.createElement('img');
|
|
8811
|
-
helpMenuIcon.src = helpIcon;
|
|
8812
|
-
(0,
|
|
8906
|
+
helpMenuIcon.src = options && options.helpIcon ? options.helpIcon : _iconBase.icons.iconBase + DEFAULT_HELP_MENU_ICON;
|
|
8907
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(helpMenuIcon, ['header-banner__help-icon']);
|
|
8813
8908
|
helpMenuContainer.appendChild(helpMenuTrigger);
|
|
8814
8909
|
helpMenuTrigger.appendChild(helpMenuIcon);
|
|
8815
|
-
var throttledMenuToggle = (0,
|
|
8910
|
+
var throttledMenuToggle = (0, _headerFooterHelpers.throttle)(function (event) {
|
|
8816
8911
|
return toggleMenu(event, helpMenuTrigger, helpMenu);
|
|
8817
8912
|
}, 50);
|
|
8818
8913
|
helpMenuTrigger.addEventListener('click', throttledMenuToggle);
|
|
@@ -8837,7 +8932,7 @@ function createHelpMenu() {
|
|
|
8837
8932
|
|
|
8838
8933
|
function createLoginSignUpButtons() {
|
|
8839
8934
|
var profileLoginButtonPre = document.createElement('div');
|
|
8840
|
-
(0,
|
|
8935
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(profileLoginButtonPre, ['header-banner__login']);
|
|
8841
8936
|
profileLoginButtonPre.appendChild((0, _authn.loginStatusBox)(document, null, {}));
|
|
8842
8937
|
return profileLoginButtonPre;
|
|
8843
8938
|
}
|
|
@@ -8848,7 +8943,7 @@ function createLoginSignUpButtons() {
|
|
|
8848
8943
|
|
|
8849
8944
|
function createUserMenuButton(label, onClick) {
|
|
8850
8945
|
var button = document.createElement('button');
|
|
8851
|
-
(0,
|
|
8946
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(button, ['header-user-menu__button']);
|
|
8852
8947
|
button.addEventListener('click', onClick);
|
|
8853
8948
|
button.innerText = label;
|
|
8854
8949
|
return button;
|
|
@@ -8860,7 +8955,7 @@ function createUserMenuButton(label, onClick) {
|
|
|
8860
8955
|
|
|
8861
8956
|
function createUserMenuLink(label, href, target) {
|
|
8862
8957
|
var link = document.createElement('a');
|
|
8863
|
-
(0,
|
|
8958
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(link, ['header-user-menu__link']);
|
|
8864
8959
|
link.href = href;
|
|
8865
8960
|
link.innerText = label;
|
|
8866
8961
|
if (target) link.target = target;
|
|
@@ -8871,7 +8966,7 @@ function createUserMenuLink(label, href, target) {
|
|
|
8871
8966
|
*/
|
|
8872
8967
|
|
|
8873
8968
|
|
|
8874
|
-
function createUserMenu(
|
|
8969
|
+
function createUserMenu(_x9, _x10, _x11) {
|
|
8875
8970
|
return _createUserMenu.apply(this, arguments);
|
|
8876
8971
|
}
|
|
8877
8972
|
/**
|
|
@@ -8880,7 +8975,7 @@ function createUserMenu(_x7, _x8, _x9) {
|
|
|
8880
8975
|
|
|
8881
8976
|
|
|
8882
8977
|
function _createUserMenu() {
|
|
8883
|
-
_createUserMenu = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(store, user,
|
|
8978
|
+
_createUserMenu = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(store, user, userMenuList) {
|
|
8884
8979
|
var fetcher, loggedInMenuList, loggedInMenu, loggedInMenuTrigger, profileImg, loggedInMenuContainer, throttledMenuToggle, timer;
|
|
8885
8980
|
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
8886
8981
|
while (1) {
|
|
@@ -8898,32 +8993,26 @@ function _createUserMenu() {
|
|
|
8898
8993
|
|
|
8899
8994
|
case 4:
|
|
8900
8995
|
loggedInMenuList = document.createElement('ul');
|
|
8901
|
-
(0,
|
|
8902
|
-
loggedInMenuList.appendChild(createUserMenuItem(createUserMenuLink('Show your profile', user.uri)));
|
|
8996
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(loggedInMenuList, ['header-user-menu__list']);
|
|
8903
8997
|
|
|
8904
|
-
if (
|
|
8905
|
-
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
|
|
8909
|
-
|
|
8910
|
-
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
});
|
|
8915
|
-
}
|
|
8998
|
+
if (userMenuList) {
|
|
8999
|
+
userMenuList.forEach(function (menuItem) {
|
|
9000
|
+
var menuItemType = menuItem.url ? 'url' : 'onclick';
|
|
9001
|
+
|
|
9002
|
+
if (menuItemType === 'url') {
|
|
9003
|
+
loggedInMenuList.appendChild(createUserMenuItem(createUserMenuLink(menuItem.label, menuItem.url, menuItem.target)));
|
|
9004
|
+
} else {
|
|
9005
|
+
loggedInMenuList.appendChild(createUserMenuItem(createUserMenuButton(menuItem.label, menuItem.onclick)));
|
|
9006
|
+
}
|
|
9007
|
+
});
|
|
8916
9008
|
}
|
|
8917
9009
|
|
|
8918
|
-
loggedInMenuList.appendChild(createUserMenuItem(createUserMenuButton('Log out', function () {
|
|
8919
|
-
return _authn.authSession.logout();
|
|
8920
|
-
})));
|
|
8921
9010
|
loggedInMenu = document.createElement('nav');
|
|
8922
|
-
(0,
|
|
9011
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(loggedInMenu, ['header-user-menu__navigation-menu']);
|
|
8923
9012
|
loggedInMenu.setAttribute('aria-hidden', 'true');
|
|
8924
9013
|
loggedInMenu.appendChild(loggedInMenuList);
|
|
8925
9014
|
loggedInMenuTrigger = document.createElement('button');
|
|
8926
|
-
(0,
|
|
9015
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(loggedInMenuTrigger, ['header-user-menu__trigger']);
|
|
8927
9016
|
loggedInMenuTrigger.type = 'button';
|
|
8928
9017
|
profileImg = getProfileImg(store, user);
|
|
8929
9018
|
|
|
@@ -8934,11 +9023,11 @@ function _createUserMenu() {
|
|
|
8934
9023
|
}
|
|
8935
9024
|
|
|
8936
9025
|
loggedInMenuContainer = document.createElement('div');
|
|
8937
|
-
(0,
|
|
8938
|
-
(0,
|
|
9026
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(loggedInMenuContainer, ['header-banner__user-menu']);
|
|
9027
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(loggedInMenuContainer, ['header-user-menu']);
|
|
8939
9028
|
loggedInMenuContainer.appendChild(loggedInMenuTrigger);
|
|
8940
9029
|
loggedInMenuContainer.appendChild(loggedInMenu);
|
|
8941
|
-
throttledMenuToggle = (0,
|
|
9030
|
+
throttledMenuToggle = (0, _headerFooterHelpers.throttle)(function (event) {
|
|
8942
9031
|
return toggleMenu(event, loggedInMenuTrigger, loggedInMenu);
|
|
8943
9032
|
}, 50);
|
|
8944
9033
|
loggedInMenuTrigger.addEventListener('click', throttledMenuToggle);
|
|
@@ -8956,7 +9045,7 @@ function _createUserMenu() {
|
|
|
8956
9045
|
});
|
|
8957
9046
|
return _context4.abrupt("return", loggedInMenuContainer);
|
|
8958
9047
|
|
|
8959
|
-
case
|
|
9048
|
+
case 27:
|
|
8960
9049
|
case "end":
|
|
8961
9050
|
return _context4.stop();
|
|
8962
9051
|
}
|
|
@@ -8968,7 +9057,7 @@ function _createUserMenu() {
|
|
|
8968
9057
|
|
|
8969
9058
|
function createUserMenuItem(child) {
|
|
8970
9059
|
var menuProfileItem = document.createElement('li');
|
|
8971
|
-
(0,
|
|
9060
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(menuProfileItem, ['header-user-menu__list-item']);
|
|
8972
9061
|
menuProfileItem.appendChild(child);
|
|
8973
9062
|
return menuProfileItem;
|
|
8974
9063
|
}
|
|
@@ -8991,7 +9080,7 @@ function getProfileImg(store, user) {
|
|
|
8991
9080
|
}
|
|
8992
9081
|
|
|
8993
9082
|
var profileImage = document.createElement('div');
|
|
8994
|
-
(0,
|
|
9083
|
+
(0, _headerFooterHelpers.addStyleClassToElement)(profileImage, ['header-user-menu__photo']);
|
|
8995
9084
|
profileImage.style.backgroundImage = "url(\"".concat(profileUrl, "\")");
|
|
8996
9085
|
return profileImage;
|
|
8997
9086
|
}
|
|
@@ -9157,11 +9246,7 @@ var styleMap = {
|
|
|
9157
9246
|
|
|
9158
9247
|
},
|
|
9159
9248
|
'header-banner__help-icon': {
|
|
9160
|
-
|
|
9161
|
-
height: '50px !important',
|
|
9162
|
-
// this is the icon size
|
|
9163
|
-
width: '55px !important' // may just be 65px round($icon-size * 352 / 430);
|
|
9164
|
-
|
|
9249
|
+
width: '28px !important'
|
|
9165
9250
|
}
|
|
9166
9251
|
};
|
|
9167
9252
|
exports.styleMap = styleMap;
|
|
@@ -9320,6 +9405,12 @@ Object.defineProperty(exports, "infiniteMessageArea", {
|
|
|
9320
9405
|
return _infinite.infiniteMessageArea;
|
|
9321
9406
|
}
|
|
9322
9407
|
});
|
|
9408
|
+
Object.defineProperty(exports, "initFooter", {
|
|
9409
|
+
enumerable: true,
|
|
9410
|
+
get: function get() {
|
|
9411
|
+
return _footer.initFooter;
|
|
9412
|
+
}
|
|
9413
|
+
});
|
|
9323
9414
|
Object.defineProperty(exports, "initHeader", {
|
|
9324
9415
|
enumerable: true,
|
|
9325
9416
|
get: function get() {
|
|
@@ -9436,6 +9527,8 @@ var _versionInfo = _interopRequireDefault(__webpack_require__(/*! ./versionInfo
|
|
|
9436
9527
|
|
|
9437
9528
|
var _header = __webpack_require__(/*! ./header */ "./lib/header/index.js");
|
|
9438
9529
|
|
|
9530
|
+
var _footer = __webpack_require__(/*! ./footer */ "./lib/footer/index.js");
|
|
9531
|
+
|
|
9439
9532
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
9440
9533
|
|
|
9441
9534
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -9488,7 +9581,8 @@ if (typeof window !== 'undefined') {
|
|
|
9488
9581
|
utils: utils,
|
|
9489
9582
|
widgets: widgets,
|
|
9490
9583
|
versionInfo: _versionInfo["default"],
|
|
9491
|
-
initHeader: _header.initHeader
|
|
9584
|
+
initHeader: _header.initHeader,
|
|
9585
|
+
initFooter: _footer.initFooter
|
|
9492
9586
|
}; // Simpler access by non-node scripts
|
|
9493
9587
|
}
|
|
9494
9588
|
//# sourceMappingURL=index.js.map
|
|
@@ -14632,6 +14726,206 @@ function isLight(x) {
|
|
|
14632
14726
|
|
|
14633
14727
|
/***/ }),
|
|
14634
14728
|
|
|
14729
|
+
/***/ "./lib/utils/headerFooterHelpers.js":
|
|
14730
|
+
/*!******************************************!*\
|
|
14731
|
+
!*** ./lib/utils/headerFooterHelpers.js ***!
|
|
14732
|
+
\******************************************/
|
|
14733
|
+
/*! no static exports found */
|
|
14734
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
14735
|
+
|
|
14736
|
+
"use strict";
|
|
14737
|
+
|
|
14738
|
+
|
|
14739
|
+
var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
|
|
14740
|
+
|
|
14741
|
+
Object.defineProperty(exports, "__esModule", {
|
|
14742
|
+
value: true
|
|
14743
|
+
});
|
|
14744
|
+
exports.addStyleClassToElement = addStyleClassToElement;
|
|
14745
|
+
exports.getName = getName;
|
|
14746
|
+
exports.getPod = getPod;
|
|
14747
|
+
exports.getPodOwner = getPodOwner;
|
|
14748
|
+
exports.throttle = throttle;
|
|
14749
|
+
|
|
14750
|
+
var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
|
|
14751
|
+
|
|
14752
|
+
var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
|
|
14753
|
+
|
|
14754
|
+
var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "./node_modules/@babel/runtime/helpers/defineProperty.js"));
|
|
14755
|
+
|
|
14756
|
+
var _rdflib = __webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js");
|
|
14757
|
+
|
|
14758
|
+
var _ = __webpack_require__(/*! .. */ "./lib/index.js");
|
|
14759
|
+
|
|
14760
|
+
var _styleMap = __webpack_require__(/*! ../header/styleMap */ "./lib/header/styleMap.js");
|
|
14761
|
+
|
|
14762
|
+
var _styleMap2 = __webpack_require__(/*! ../footer/styleMap */ "./lib/footer/styleMap.js");
|
|
14763
|
+
|
|
14764
|
+
var _jss = __webpack_require__(/*! ../jss */ "./lib/jss/index.js");
|
|
14765
|
+
|
|
14766
|
+
/*
|
|
14767
|
+
Copied from mashlib/src/global/metadata.ts
|
|
14768
|
+
*/
|
|
14769
|
+
|
|
14770
|
+
/**
|
|
14771
|
+
* @internal
|
|
14772
|
+
*/
|
|
14773
|
+
function getStyle(styleClass, type) {
|
|
14774
|
+
if (type && type === 'footer') {
|
|
14775
|
+
return _styleMap2.styleMap[styleClass];
|
|
14776
|
+
} else {
|
|
14777
|
+
return _styleMap.styleMap[styleClass];
|
|
14778
|
+
}
|
|
14779
|
+
}
|
|
14780
|
+
/**
|
|
14781
|
+
* @ignore exporting this only for the unit test
|
|
14782
|
+
*/
|
|
14783
|
+
|
|
14784
|
+
|
|
14785
|
+
function addStyleClassToElement(element, styleClasses, type) {
|
|
14786
|
+
styleClasses.forEach(function (styleClass) {
|
|
14787
|
+
var style = getStyle(styleClass, type);
|
|
14788
|
+
|
|
14789
|
+
var _getClasses = (0, _jss.getClasses)(document.head, (0, _defineProperty2["default"])({}, styleClass, style)),
|
|
14790
|
+
classes = _getClasses.classes;
|
|
14791
|
+
|
|
14792
|
+
element.classList.add(classes[styleClass]);
|
|
14793
|
+
});
|
|
14794
|
+
}
|
|
14795
|
+
/**
|
|
14796
|
+
* @ignore exporting this only for the unit test
|
|
14797
|
+
*/
|
|
14798
|
+
|
|
14799
|
+
|
|
14800
|
+
function getPod() {
|
|
14801
|
+
// @@ TODO: This is given that mashlib runs on NSS - might need to change when we want it to run on other Pod servers
|
|
14802
|
+
return (0, _rdflib.sym)(document.location.origin).site();
|
|
14803
|
+
}
|
|
14804
|
+
/**
|
|
14805
|
+
* @ignore exporting this only for the unit test
|
|
14806
|
+
*/
|
|
14807
|
+
|
|
14808
|
+
|
|
14809
|
+
function getPodOwner(_x, _x2) {
|
|
14810
|
+
return _getPodOwner.apply(this, arguments);
|
|
14811
|
+
}
|
|
14812
|
+
/**
|
|
14813
|
+
* @ignore exporting this only for the unit test
|
|
14814
|
+
*/
|
|
14815
|
+
|
|
14816
|
+
|
|
14817
|
+
function _getPodOwner() {
|
|
14818
|
+
_getPodOwner = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(pod, store) {
|
|
14819
|
+
var podOwner, storageIsListedInPodOwnersProfile;
|
|
14820
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
14821
|
+
while (1) {
|
|
14822
|
+
switch (_context.prev = _context.next) {
|
|
14823
|
+
case 0:
|
|
14824
|
+
// @@ TODO: This is given the structure that NSS provides - might need to change for other Pod servers
|
|
14825
|
+
podOwner = (0, _rdflib.sym)("".concat(pod.uri, "profile/card#me"));
|
|
14826
|
+
_context.prev = 1;
|
|
14827
|
+
|
|
14828
|
+
if (!store.fetcher) {
|
|
14829
|
+
_context.next = 7;
|
|
14830
|
+
break;
|
|
14831
|
+
}
|
|
14832
|
+
|
|
14833
|
+
_context.next = 5;
|
|
14834
|
+
return store.fetcher.load(podOwner.doc());
|
|
14835
|
+
|
|
14836
|
+
case 5:
|
|
14837
|
+
_context.next = 8;
|
|
14838
|
+
break;
|
|
14839
|
+
|
|
14840
|
+
case 7:
|
|
14841
|
+
throw new Error('There was a problem loading the Fetcher');
|
|
14842
|
+
|
|
14843
|
+
case 8:
|
|
14844
|
+
_context.next = 13;
|
|
14845
|
+
break;
|
|
14846
|
+
|
|
14847
|
+
case 10:
|
|
14848
|
+
_context.prev = 10;
|
|
14849
|
+
_context.t0 = _context["catch"](1);
|
|
14850
|
+
throw new Error('Did NOT find pod owners profile at ' + podOwner);
|
|
14851
|
+
|
|
14852
|
+
case 13:
|
|
14853
|
+
if (!podOwner) {
|
|
14854
|
+
_context.next = 17;
|
|
14855
|
+
break;
|
|
14856
|
+
}
|
|
14857
|
+
|
|
14858
|
+
storageIsListedInPodOwnersProfile = store.holds(podOwner, _.ns.space('storage'), pod, podOwner.doc());
|
|
14859
|
+
|
|
14860
|
+
if (storageIsListedInPodOwnersProfile) {
|
|
14861
|
+
_context.next = 17;
|
|
14862
|
+
break;
|
|
14863
|
+
}
|
|
14864
|
+
|
|
14865
|
+
throw new Error("** Pod owner ".concat(podOwner, " does NOT list pod ").concat(pod, " as storage"));
|
|
14866
|
+
|
|
14867
|
+
case 17:
|
|
14868
|
+
return _context.abrupt("return", podOwner);
|
|
14869
|
+
|
|
14870
|
+
case 18:
|
|
14871
|
+
case "end":
|
|
14872
|
+
return _context.stop();
|
|
14873
|
+
}
|
|
14874
|
+
}
|
|
14875
|
+
}, _callee, null, [[1, 10]]);
|
|
14876
|
+
}));
|
|
14877
|
+
return _getPodOwner.apply(this, arguments);
|
|
14878
|
+
}
|
|
14879
|
+
|
|
14880
|
+
function getName(store, user) {
|
|
14881
|
+
return store.anyValue(user, _.ns.vcard('fn'), null, user.doc()) || store.anyValue(user, _.ns.foaf('name'), null, user.doc()) || user.uri;
|
|
14882
|
+
}
|
|
14883
|
+
/**
|
|
14884
|
+
* @ignore exporting this only for the unit test
|
|
14885
|
+
*/
|
|
14886
|
+
|
|
14887
|
+
|
|
14888
|
+
function throttle(func, wait) {
|
|
14889
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
14890
|
+
var context, args, result;
|
|
14891
|
+
var timeout = null;
|
|
14892
|
+
var previous = 0;
|
|
14893
|
+
|
|
14894
|
+
var later = function later() {
|
|
14895
|
+
previous = !options.leading ? 0 : Date.now();
|
|
14896
|
+
timeout = null;
|
|
14897
|
+
result = func.apply(context, args);
|
|
14898
|
+
if (!timeout) context = args = null;
|
|
14899
|
+
};
|
|
14900
|
+
|
|
14901
|
+
return function () {
|
|
14902
|
+
var now = Date.now();
|
|
14903
|
+
if (!previous && !options.leading) previous = now;
|
|
14904
|
+
var remaining = wait - (now - previous); // @ts-ignore
|
|
14905
|
+
|
|
14906
|
+
context = this;
|
|
14907
|
+
args = arguments;
|
|
14908
|
+
|
|
14909
|
+
if (remaining <= 0 || remaining > wait) {
|
|
14910
|
+
if (timeout) {
|
|
14911
|
+
clearTimeout(timeout);
|
|
14912
|
+
timeout = null;
|
|
14913
|
+
}
|
|
14914
|
+
|
|
14915
|
+
previous = now;
|
|
14916
|
+
result = func.apply(context, args);
|
|
14917
|
+
if (!timeout) context = args = null;
|
|
14918
|
+
} else if (!timeout && options.trailing !== false) {
|
|
14919
|
+
timeout = setTimeout(later, remaining);
|
|
14920
|
+
}
|
|
14921
|
+
|
|
14922
|
+
return result;
|
|
14923
|
+
};
|
|
14924
|
+
}
|
|
14925
|
+
//# sourceMappingURL=headerFooterHelpers.js.map
|
|
14926
|
+
|
|
14927
|
+
/***/ }),
|
|
14928
|
+
|
|
14635
14929
|
/***/ "./lib/utils/index.js":
|
|
14636
14930
|
/*!****************************!*\
|
|
14637
14931
|
!*** ./lib/utils/index.js ***!
|
|
@@ -15428,10 +15722,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
15428
15722
|
});
|
|
15429
15723
|
exports["default"] = void 0;
|
|
15430
15724
|
var _default = {
|
|
15431
|
-
buildTime: '
|
|
15432
|
-
commit: '
|
|
15725
|
+
buildTime: '2022-01-04T09:49:10Z',
|
|
15726
|
+
commit: '6a9e81a980072cb7f7b8e8098346bd1acac55269',
|
|
15433
15727
|
npmInfo: {
|
|
15434
|
-
'solid-ui': '2.4.
|
|
15728
|
+
'solid-ui': '2.4.14',
|
|
15435
15729
|
npm: '6.14.15',
|
|
15436
15730
|
ares: '1.18.1',
|
|
15437
15731
|
brotli: '1.0.9',
|
|
@@ -26258,6 +26552,2999 @@ class AggregateHandler {
|
|
|
26258
26552
|
exports.default = AggregateHandler;
|
|
26259
26553
|
//# sourceMappingURL=AggregateHandler.js.map
|
|
26260
26554
|
|
|
26555
|
+
/***/ }),
|
|
26556
|
+
|
|
26557
|
+
/***/ "./node_modules/@xmldom/xmldom/lib/conventions.js":
|
|
26558
|
+
/*!********************************************************!*\
|
|
26559
|
+
!*** ./node_modules/@xmldom/xmldom/lib/conventions.js ***!
|
|
26560
|
+
\********************************************************/
|
|
26561
|
+
/*! no static exports found */
|
|
26562
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
26563
|
+
|
|
26564
|
+
"use strict";
|
|
26565
|
+
|
|
26566
|
+
|
|
26567
|
+
/**
|
|
26568
|
+
* "Shallow freezes" an object to render it immutable.
|
|
26569
|
+
* Uses `Object.freeze` if available,
|
|
26570
|
+
* otherwise the immutability is only in the type.
|
|
26571
|
+
*
|
|
26572
|
+
* Is used to create "enum like" objects.
|
|
26573
|
+
*
|
|
26574
|
+
* @template T
|
|
26575
|
+
* @param {T} object the object to freeze
|
|
26576
|
+
* @param {Pick<ObjectConstructor, 'freeze'> = Object} oc `Object` by default,
|
|
26577
|
+
* allows to inject custom object constructor for tests
|
|
26578
|
+
* @returns {Readonly<T>}
|
|
26579
|
+
*
|
|
26580
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
|
|
26581
|
+
*/
|
|
26582
|
+
function freeze(object, oc) {
|
|
26583
|
+
if (oc === undefined) {
|
|
26584
|
+
oc = Object
|
|
26585
|
+
}
|
|
26586
|
+
return oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object
|
|
26587
|
+
}
|
|
26588
|
+
|
|
26589
|
+
/**
|
|
26590
|
+
* All mime types that are allowed as input to `DOMParser.parseFromString`
|
|
26591
|
+
*
|
|
26592
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02 MDN
|
|
26593
|
+
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype WHATWG HTML Spec
|
|
26594
|
+
* @see DOMParser.prototype.parseFromString
|
|
26595
|
+
*/
|
|
26596
|
+
var MIME_TYPE = freeze({
|
|
26597
|
+
/**
|
|
26598
|
+
* `text/html`, the only mime type that triggers treating an XML document as HTML.
|
|
26599
|
+
*
|
|
26600
|
+
* @see DOMParser.SupportedType.isHTML
|
|
26601
|
+
* @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
|
|
26602
|
+
* @see https://en.wikipedia.org/wiki/HTML Wikipedia
|
|
26603
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
|
|
26604
|
+
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring WHATWG HTML Spec
|
|
26605
|
+
*/
|
|
26606
|
+
HTML: 'text/html',
|
|
26607
|
+
|
|
26608
|
+
/**
|
|
26609
|
+
* Helper method to check a mime type if it indicates an HTML document
|
|
26610
|
+
*
|
|
26611
|
+
* @param {string} [value]
|
|
26612
|
+
* @returns {boolean}
|
|
26613
|
+
*
|
|
26614
|
+
* @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
|
|
26615
|
+
* @see https://en.wikipedia.org/wiki/HTML Wikipedia
|
|
26616
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
|
|
26617
|
+
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring */
|
|
26618
|
+
isHTML: function (value) {
|
|
26619
|
+
return value === MIME_TYPE.HTML
|
|
26620
|
+
},
|
|
26621
|
+
|
|
26622
|
+
/**
|
|
26623
|
+
* `application/xml`, the standard mime type for XML documents.
|
|
26624
|
+
*
|
|
26625
|
+
* @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType registration
|
|
26626
|
+
* @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303
|
|
26627
|
+
* @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
|
|
26628
|
+
*/
|
|
26629
|
+
XML_APPLICATION: 'application/xml',
|
|
26630
|
+
|
|
26631
|
+
/**
|
|
26632
|
+
* `text/html`, an alias for `application/xml`.
|
|
26633
|
+
*
|
|
26634
|
+
* @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303
|
|
26635
|
+
* @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration
|
|
26636
|
+
* @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
|
|
26637
|
+
*/
|
|
26638
|
+
XML_TEXT: 'text/xml',
|
|
26639
|
+
|
|
26640
|
+
/**
|
|
26641
|
+
* `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,
|
|
26642
|
+
* but is parsed as an XML document.
|
|
26643
|
+
*
|
|
26644
|
+
* @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType registration
|
|
26645
|
+
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec
|
|
26646
|
+
* @see https://en.wikipedia.org/wiki/XHTML Wikipedia
|
|
26647
|
+
*/
|
|
26648
|
+
XML_XHTML_APPLICATION: 'application/xhtml+xml',
|
|
26649
|
+
|
|
26650
|
+
/**
|
|
26651
|
+
* `image/svg+xml`,
|
|
26652
|
+
*
|
|
26653
|
+
* @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration
|
|
26654
|
+
* @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1
|
|
26655
|
+
* @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia
|
|
26656
|
+
*/
|
|
26657
|
+
XML_SVG_IMAGE: 'image/svg+xml',
|
|
26658
|
+
})
|
|
26659
|
+
|
|
26660
|
+
/**
|
|
26661
|
+
* Namespaces that are used in this code base.
|
|
26662
|
+
*
|
|
26663
|
+
* @see http://www.w3.org/TR/REC-xml-names
|
|
26664
|
+
*/
|
|
26665
|
+
var NAMESPACE = freeze({
|
|
26666
|
+
/**
|
|
26667
|
+
* The XHTML namespace.
|
|
26668
|
+
*
|
|
26669
|
+
* @see http://www.w3.org/1999/xhtml
|
|
26670
|
+
*/
|
|
26671
|
+
HTML: 'http://www.w3.org/1999/xhtml',
|
|
26672
|
+
|
|
26673
|
+
/**
|
|
26674
|
+
* Checks if `uri` equals `NAMESPACE.HTML`.
|
|
26675
|
+
*
|
|
26676
|
+
* @param {string} [uri]
|
|
26677
|
+
*
|
|
26678
|
+
* @see NAMESPACE.HTML
|
|
26679
|
+
*/
|
|
26680
|
+
isHTML: function (uri) {
|
|
26681
|
+
return uri === NAMESPACE.HTML
|
|
26682
|
+
},
|
|
26683
|
+
|
|
26684
|
+
/**
|
|
26685
|
+
* The SVG namespace.
|
|
26686
|
+
*
|
|
26687
|
+
* @see http://www.w3.org/2000/svg
|
|
26688
|
+
*/
|
|
26689
|
+
SVG: 'http://www.w3.org/2000/svg',
|
|
26690
|
+
|
|
26691
|
+
/**
|
|
26692
|
+
* The `xml:` namespace.
|
|
26693
|
+
*
|
|
26694
|
+
* @see http://www.w3.org/XML/1998/namespace
|
|
26695
|
+
*/
|
|
26696
|
+
XML: 'http://www.w3.org/XML/1998/namespace',
|
|
26697
|
+
|
|
26698
|
+
/**
|
|
26699
|
+
* The `xmlns:` namespace
|
|
26700
|
+
*
|
|
26701
|
+
* @see https://www.w3.org/2000/xmlns/
|
|
26702
|
+
*/
|
|
26703
|
+
XMLNS: 'http://www.w3.org/2000/xmlns/',
|
|
26704
|
+
})
|
|
26705
|
+
|
|
26706
|
+
exports.freeze = freeze;
|
|
26707
|
+
exports.MIME_TYPE = MIME_TYPE;
|
|
26708
|
+
exports.NAMESPACE = NAMESPACE;
|
|
26709
|
+
|
|
26710
|
+
|
|
26711
|
+
/***/ }),
|
|
26712
|
+
|
|
26713
|
+
/***/ "./node_modules/@xmldom/xmldom/lib/dom-parser.js":
|
|
26714
|
+
/*!*******************************************************!*\
|
|
26715
|
+
!*** ./node_modules/@xmldom/xmldom/lib/dom-parser.js ***!
|
|
26716
|
+
\*******************************************************/
|
|
26717
|
+
/*! no static exports found */
|
|
26718
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
26719
|
+
|
|
26720
|
+
var conventions = __webpack_require__(/*! ./conventions */ "./node_modules/@xmldom/xmldom/lib/conventions.js");
|
|
26721
|
+
var dom = __webpack_require__(/*! ./dom */ "./node_modules/@xmldom/xmldom/lib/dom.js")
|
|
26722
|
+
var entities = __webpack_require__(/*! ./entities */ "./node_modules/@xmldom/xmldom/lib/entities.js");
|
|
26723
|
+
var sax = __webpack_require__(/*! ./sax */ "./node_modules/@xmldom/xmldom/lib/sax.js");
|
|
26724
|
+
|
|
26725
|
+
var DOMImplementation = dom.DOMImplementation;
|
|
26726
|
+
|
|
26727
|
+
var NAMESPACE = conventions.NAMESPACE;
|
|
26728
|
+
|
|
26729
|
+
var ParseError = sax.ParseError;
|
|
26730
|
+
var XMLReader = sax.XMLReader;
|
|
26731
|
+
|
|
26732
|
+
/**
|
|
26733
|
+
* Normalizes line ending according to https://www.w3.org/TR/xml11/#sec-line-ends:
|
|
26734
|
+
*
|
|
26735
|
+
* > XML parsed entities are often stored in computer files which,
|
|
26736
|
+
* > for editing convenience, are organized into lines.
|
|
26737
|
+
* > These lines are typically separated by some combination
|
|
26738
|
+
* > of the characters CARRIAGE RETURN (#xD) and LINE FEED (#xA).
|
|
26739
|
+
* >
|
|
26740
|
+
* > To simplify the tasks of applications, the XML processor must behave
|
|
26741
|
+
* > as if it normalized all line breaks in external parsed entities (including the document entity)
|
|
26742
|
+
* > on input, before parsing, by translating all of the following to a single #xA character:
|
|
26743
|
+
* >
|
|
26744
|
+
* > 1. the two-character sequence #xD #xA
|
|
26745
|
+
* > 2. the two-character sequence #xD #x85
|
|
26746
|
+
* > 3. the single character #x85
|
|
26747
|
+
* > 4. the single character #x2028
|
|
26748
|
+
* > 5. any #xD character that is not immediately followed by #xA or #x85.
|
|
26749
|
+
*
|
|
26750
|
+
* @param {string} input
|
|
26751
|
+
* @returns {string}
|
|
26752
|
+
*/
|
|
26753
|
+
function normalizeLineEndings(input) {
|
|
26754
|
+
return input
|
|
26755
|
+
.replace(/\r[\n\u0085]/g, '\n')
|
|
26756
|
+
.replace(/[\r\u0085\u2028]/g, '\n')
|
|
26757
|
+
}
|
|
26758
|
+
|
|
26759
|
+
/**
|
|
26760
|
+
* @typedef Locator
|
|
26761
|
+
* @property {number} [columnNumber]
|
|
26762
|
+
* @property {number} [lineNumber]
|
|
26763
|
+
*/
|
|
26764
|
+
|
|
26765
|
+
/**
|
|
26766
|
+
* @typedef DOMParserOptions
|
|
26767
|
+
* @property {DOMHandler} [domBuilder]
|
|
26768
|
+
* @property {Function} [errorHandler]
|
|
26769
|
+
* @property {(string) => string} [normalizeLineEndings] used to replace line endings before parsing
|
|
26770
|
+
* defaults to `normalizeLineEndings`
|
|
26771
|
+
* @property {Locator} [locator]
|
|
26772
|
+
* @property {Record<string, string>} [xmlns]
|
|
26773
|
+
*
|
|
26774
|
+
* @see normalizeLineEndings
|
|
26775
|
+
*/
|
|
26776
|
+
|
|
26777
|
+
/**
|
|
26778
|
+
* The DOMParser interface provides the ability to parse XML or HTML source code
|
|
26779
|
+
* from a string into a DOM `Document`.
|
|
26780
|
+
*
|
|
26781
|
+
* _xmldom is different from the spec in that it allows an `options` parameter,
|
|
26782
|
+
* to override the default behavior._
|
|
26783
|
+
*
|
|
26784
|
+
* @param {DOMParserOptions} [options]
|
|
26785
|
+
* @constructor
|
|
26786
|
+
*
|
|
26787
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
|
|
26788
|
+
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
|
|
26789
|
+
*/
|
|
26790
|
+
function DOMParser(options){
|
|
26791
|
+
this.options = options ||{locator:{}};
|
|
26792
|
+
}
|
|
26793
|
+
|
|
26794
|
+
DOMParser.prototype.parseFromString = function(source,mimeType){
|
|
26795
|
+
var options = this.options;
|
|
26796
|
+
var sax = new XMLReader();
|
|
26797
|
+
var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler
|
|
26798
|
+
var errorHandler = options.errorHandler;
|
|
26799
|
+
var locator = options.locator;
|
|
26800
|
+
var defaultNSMap = options.xmlns||{};
|
|
26801
|
+
var isHTML = /\/x?html?$/.test(mimeType);//mimeType.toLowerCase().indexOf('html') > -1;
|
|
26802
|
+
var entityMap = isHTML ? entities.HTML_ENTITIES : entities.XML_ENTITIES;
|
|
26803
|
+
if(locator){
|
|
26804
|
+
domBuilder.setDocumentLocator(locator)
|
|
26805
|
+
}
|
|
26806
|
+
|
|
26807
|
+
sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator);
|
|
26808
|
+
sax.domBuilder = options.domBuilder || domBuilder;
|
|
26809
|
+
if(isHTML){
|
|
26810
|
+
defaultNSMap[''] = NAMESPACE.HTML;
|
|
26811
|
+
}
|
|
26812
|
+
defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;
|
|
26813
|
+
var normalize = options.normalizeLineEndings || normalizeLineEndings;
|
|
26814
|
+
if (source && typeof source === 'string') {
|
|
26815
|
+
sax.parse(
|
|
26816
|
+
normalize(source),
|
|
26817
|
+
defaultNSMap,
|
|
26818
|
+
entityMap
|
|
26819
|
+
)
|
|
26820
|
+
} else {
|
|
26821
|
+
sax.errorHandler.error('invalid doc source')
|
|
26822
|
+
}
|
|
26823
|
+
return domBuilder.doc;
|
|
26824
|
+
}
|
|
26825
|
+
function buildErrorHandler(errorImpl,domBuilder,locator){
|
|
26826
|
+
if(!errorImpl){
|
|
26827
|
+
if(domBuilder instanceof DOMHandler){
|
|
26828
|
+
return domBuilder;
|
|
26829
|
+
}
|
|
26830
|
+
errorImpl = domBuilder ;
|
|
26831
|
+
}
|
|
26832
|
+
var errorHandler = {}
|
|
26833
|
+
var isCallback = errorImpl instanceof Function;
|
|
26834
|
+
locator = locator||{}
|
|
26835
|
+
function build(key){
|
|
26836
|
+
var fn = errorImpl[key];
|
|
26837
|
+
if(!fn && isCallback){
|
|
26838
|
+
fn = errorImpl.length == 2?function(msg){errorImpl(key,msg)}:errorImpl;
|
|
26839
|
+
}
|
|
26840
|
+
errorHandler[key] = fn && function(msg){
|
|
26841
|
+
fn('[xmldom '+key+']\t'+msg+_locator(locator));
|
|
26842
|
+
}||function(){};
|
|
26843
|
+
}
|
|
26844
|
+
build('warning');
|
|
26845
|
+
build('error');
|
|
26846
|
+
build('fatalError');
|
|
26847
|
+
return errorHandler;
|
|
26848
|
+
}
|
|
26849
|
+
|
|
26850
|
+
//console.log('#\n\n\n\n\n\n\n####')
|
|
26851
|
+
/**
|
|
26852
|
+
* +ContentHandler+ErrorHandler
|
|
26853
|
+
* +LexicalHandler+EntityResolver2
|
|
26854
|
+
* -DeclHandler-DTDHandler
|
|
26855
|
+
*
|
|
26856
|
+
* DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler
|
|
26857
|
+
* DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2
|
|
26858
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html
|
|
26859
|
+
*/
|
|
26860
|
+
function DOMHandler() {
|
|
26861
|
+
this.cdata = false;
|
|
26862
|
+
}
|
|
26863
|
+
function position(locator,node){
|
|
26864
|
+
node.lineNumber = locator.lineNumber;
|
|
26865
|
+
node.columnNumber = locator.columnNumber;
|
|
26866
|
+
}
|
|
26867
|
+
/**
|
|
26868
|
+
* @see org.xml.sax.ContentHandler#startDocument
|
|
26869
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
|
|
26870
|
+
*/
|
|
26871
|
+
DOMHandler.prototype = {
|
|
26872
|
+
startDocument : function() {
|
|
26873
|
+
this.doc = new DOMImplementation().createDocument(null, null, null);
|
|
26874
|
+
if (this.locator) {
|
|
26875
|
+
this.doc.documentURI = this.locator.systemId;
|
|
26876
|
+
}
|
|
26877
|
+
},
|
|
26878
|
+
startElement:function(namespaceURI, localName, qName, attrs) {
|
|
26879
|
+
var doc = this.doc;
|
|
26880
|
+
var el = doc.createElementNS(namespaceURI, qName||localName);
|
|
26881
|
+
var len = attrs.length;
|
|
26882
|
+
appendElement(this, el);
|
|
26883
|
+
this.currentElement = el;
|
|
26884
|
+
|
|
26885
|
+
this.locator && position(this.locator,el)
|
|
26886
|
+
for (var i = 0 ; i < len; i++) {
|
|
26887
|
+
var namespaceURI = attrs.getURI(i);
|
|
26888
|
+
var value = attrs.getValue(i);
|
|
26889
|
+
var qName = attrs.getQName(i);
|
|
26890
|
+
var attr = doc.createAttributeNS(namespaceURI, qName);
|
|
26891
|
+
this.locator &&position(attrs.getLocator(i),attr);
|
|
26892
|
+
attr.value = attr.nodeValue = value;
|
|
26893
|
+
el.setAttributeNode(attr)
|
|
26894
|
+
}
|
|
26895
|
+
},
|
|
26896
|
+
endElement:function(namespaceURI, localName, qName) {
|
|
26897
|
+
var current = this.currentElement
|
|
26898
|
+
var tagName = current.tagName;
|
|
26899
|
+
this.currentElement = current.parentNode;
|
|
26900
|
+
},
|
|
26901
|
+
startPrefixMapping:function(prefix, uri) {
|
|
26902
|
+
},
|
|
26903
|
+
endPrefixMapping:function(prefix) {
|
|
26904
|
+
},
|
|
26905
|
+
processingInstruction:function(target, data) {
|
|
26906
|
+
var ins = this.doc.createProcessingInstruction(target, data);
|
|
26907
|
+
this.locator && position(this.locator,ins)
|
|
26908
|
+
appendElement(this, ins);
|
|
26909
|
+
},
|
|
26910
|
+
ignorableWhitespace:function(ch, start, length) {
|
|
26911
|
+
},
|
|
26912
|
+
characters:function(chars, start, length) {
|
|
26913
|
+
chars = _toString.apply(this,arguments)
|
|
26914
|
+
//console.log(chars)
|
|
26915
|
+
if(chars){
|
|
26916
|
+
if (this.cdata) {
|
|
26917
|
+
var charNode = this.doc.createCDATASection(chars);
|
|
26918
|
+
} else {
|
|
26919
|
+
var charNode = this.doc.createTextNode(chars);
|
|
26920
|
+
}
|
|
26921
|
+
if(this.currentElement){
|
|
26922
|
+
this.currentElement.appendChild(charNode);
|
|
26923
|
+
}else if(/^\s*$/.test(chars)){
|
|
26924
|
+
this.doc.appendChild(charNode);
|
|
26925
|
+
//process xml
|
|
26926
|
+
}
|
|
26927
|
+
this.locator && position(this.locator,charNode)
|
|
26928
|
+
}
|
|
26929
|
+
},
|
|
26930
|
+
skippedEntity:function(name) {
|
|
26931
|
+
},
|
|
26932
|
+
endDocument:function() {
|
|
26933
|
+
this.doc.normalize();
|
|
26934
|
+
},
|
|
26935
|
+
setDocumentLocator:function (locator) {
|
|
26936
|
+
if(this.locator = locator){// && !('lineNumber' in locator)){
|
|
26937
|
+
locator.lineNumber = 0;
|
|
26938
|
+
}
|
|
26939
|
+
},
|
|
26940
|
+
//LexicalHandler
|
|
26941
|
+
comment:function(chars, start, length) {
|
|
26942
|
+
chars = _toString.apply(this,arguments)
|
|
26943
|
+
var comm = this.doc.createComment(chars);
|
|
26944
|
+
this.locator && position(this.locator,comm)
|
|
26945
|
+
appendElement(this, comm);
|
|
26946
|
+
},
|
|
26947
|
+
|
|
26948
|
+
startCDATA:function() {
|
|
26949
|
+
//used in characters() methods
|
|
26950
|
+
this.cdata = true;
|
|
26951
|
+
},
|
|
26952
|
+
endCDATA:function() {
|
|
26953
|
+
this.cdata = false;
|
|
26954
|
+
},
|
|
26955
|
+
|
|
26956
|
+
startDTD:function(name, publicId, systemId) {
|
|
26957
|
+
var impl = this.doc.implementation;
|
|
26958
|
+
if (impl && impl.createDocumentType) {
|
|
26959
|
+
var dt = impl.createDocumentType(name, publicId, systemId);
|
|
26960
|
+
this.locator && position(this.locator,dt)
|
|
26961
|
+
appendElement(this, dt);
|
|
26962
|
+
this.doc.doctype = dt;
|
|
26963
|
+
}
|
|
26964
|
+
},
|
|
26965
|
+
/**
|
|
26966
|
+
* @see org.xml.sax.ErrorHandler
|
|
26967
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
|
|
26968
|
+
*/
|
|
26969
|
+
warning:function(error) {
|
|
26970
|
+
console.warn('[xmldom warning]\t'+error,_locator(this.locator));
|
|
26971
|
+
},
|
|
26972
|
+
error:function(error) {
|
|
26973
|
+
console.error('[xmldom error]\t'+error,_locator(this.locator));
|
|
26974
|
+
},
|
|
26975
|
+
fatalError:function(error) {
|
|
26976
|
+
throw new ParseError(error, this.locator);
|
|
26977
|
+
}
|
|
26978
|
+
}
|
|
26979
|
+
function _locator(l){
|
|
26980
|
+
if(l){
|
|
26981
|
+
return '\n@'+(l.systemId ||'')+'#[line:'+l.lineNumber+',col:'+l.columnNumber+']'
|
|
26982
|
+
}
|
|
26983
|
+
}
|
|
26984
|
+
function _toString(chars,start,length){
|
|
26985
|
+
if(typeof chars == 'string'){
|
|
26986
|
+
return chars.substr(start,length)
|
|
26987
|
+
}else{//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
|
|
26988
|
+
if(chars.length >= start+length || start){
|
|
26989
|
+
return new java.lang.String(chars,start,length)+'';
|
|
26990
|
+
}
|
|
26991
|
+
return chars;
|
|
26992
|
+
}
|
|
26993
|
+
}
|
|
26994
|
+
|
|
26995
|
+
/*
|
|
26996
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
|
|
26997
|
+
* used method of org.xml.sax.ext.LexicalHandler:
|
|
26998
|
+
* #comment(chars, start, length)
|
|
26999
|
+
* #startCDATA()
|
|
27000
|
+
* #endCDATA()
|
|
27001
|
+
* #startDTD(name, publicId, systemId)
|
|
27002
|
+
*
|
|
27003
|
+
*
|
|
27004
|
+
* IGNORED method of org.xml.sax.ext.LexicalHandler:
|
|
27005
|
+
* #endDTD()
|
|
27006
|
+
* #startEntity(name)
|
|
27007
|
+
* #endEntity(name)
|
|
27008
|
+
*
|
|
27009
|
+
*
|
|
27010
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
|
|
27011
|
+
* IGNORED method of org.xml.sax.ext.DeclHandler
|
|
27012
|
+
* #attributeDecl(eName, aName, type, mode, value)
|
|
27013
|
+
* #elementDecl(name, model)
|
|
27014
|
+
* #externalEntityDecl(name, publicId, systemId)
|
|
27015
|
+
* #internalEntityDecl(name, value)
|
|
27016
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
|
|
27017
|
+
* IGNORED method of org.xml.sax.EntityResolver2
|
|
27018
|
+
* #resolveEntity(String name,String publicId,String baseURI,String systemId)
|
|
27019
|
+
* #resolveEntity(publicId, systemId)
|
|
27020
|
+
* #getExternalSubset(name, baseURI)
|
|
27021
|
+
* @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
|
|
27022
|
+
* IGNORED method of org.xml.sax.DTDHandler
|
|
27023
|
+
* #notationDecl(name, publicId, systemId) {};
|
|
27024
|
+
* #unparsedEntityDecl(name, publicId, systemId, notationName) {};
|
|
27025
|
+
*/
|
|
27026
|
+
"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){
|
|
27027
|
+
DOMHandler.prototype[key] = function(){return null}
|
|
27028
|
+
})
|
|
27029
|
+
|
|
27030
|
+
/* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */
|
|
27031
|
+
function appendElement (hander,node) {
|
|
27032
|
+
if (!hander.currentElement) {
|
|
27033
|
+
hander.doc.appendChild(node);
|
|
27034
|
+
} else {
|
|
27035
|
+
hander.currentElement.appendChild(node);
|
|
27036
|
+
}
|
|
27037
|
+
}//appendChild and setAttributeNS are preformance key
|
|
27038
|
+
|
|
27039
|
+
exports.__DOMHandler = DOMHandler;
|
|
27040
|
+
exports.normalizeLineEndings = normalizeLineEndings;
|
|
27041
|
+
exports.DOMParser = DOMParser;
|
|
27042
|
+
|
|
27043
|
+
|
|
27044
|
+
/***/ }),
|
|
27045
|
+
|
|
27046
|
+
/***/ "./node_modules/@xmldom/xmldom/lib/dom.js":
|
|
27047
|
+
/*!************************************************!*\
|
|
27048
|
+
!*** ./node_modules/@xmldom/xmldom/lib/dom.js ***!
|
|
27049
|
+
\************************************************/
|
|
27050
|
+
/*! no static exports found */
|
|
27051
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
27052
|
+
|
|
27053
|
+
var conventions = __webpack_require__(/*! ./conventions */ "./node_modules/@xmldom/xmldom/lib/conventions.js");
|
|
27054
|
+
|
|
27055
|
+
var NAMESPACE = conventions.NAMESPACE;
|
|
27056
|
+
|
|
27057
|
+
/**
|
|
27058
|
+
* A prerequisite for `[].filter`, to drop elements that are empty
|
|
27059
|
+
* @param {string} input
|
|
27060
|
+
* @returns {boolean}
|
|
27061
|
+
*/
|
|
27062
|
+
function notEmptyString (input) {
|
|
27063
|
+
return input !== ''
|
|
27064
|
+
}
|
|
27065
|
+
/**
|
|
27066
|
+
* @see https://infra.spec.whatwg.org/#split-on-ascii-whitespace
|
|
27067
|
+
* @see https://infra.spec.whatwg.org/#ascii-whitespace
|
|
27068
|
+
*
|
|
27069
|
+
* @param {string} input
|
|
27070
|
+
* @returns {string[]} (can be empty)
|
|
27071
|
+
*/
|
|
27072
|
+
function splitOnASCIIWhitespace(input) {
|
|
27073
|
+
// U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, U+0020 SPACE
|
|
27074
|
+
return input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : []
|
|
27075
|
+
}
|
|
27076
|
+
|
|
27077
|
+
/**
|
|
27078
|
+
* Adds element as a key to current if it is not already present.
|
|
27079
|
+
*
|
|
27080
|
+
* @param {Record<string, boolean | undefined>} current
|
|
27081
|
+
* @param {string} element
|
|
27082
|
+
* @returns {Record<string, boolean | undefined>}
|
|
27083
|
+
*/
|
|
27084
|
+
function orderedSetReducer (current, element) {
|
|
27085
|
+
if (!current.hasOwnProperty(element)) {
|
|
27086
|
+
current[element] = true;
|
|
27087
|
+
}
|
|
27088
|
+
return current;
|
|
27089
|
+
}
|
|
27090
|
+
|
|
27091
|
+
/**
|
|
27092
|
+
* @see https://infra.spec.whatwg.org/#ordered-set
|
|
27093
|
+
* @param {string} input
|
|
27094
|
+
* @returns {string[]}
|
|
27095
|
+
*/
|
|
27096
|
+
function toOrderedSet(input) {
|
|
27097
|
+
if (!input) return [];
|
|
27098
|
+
var list = splitOnASCIIWhitespace(input);
|
|
27099
|
+
return Object.keys(list.reduce(orderedSetReducer, {}))
|
|
27100
|
+
}
|
|
27101
|
+
|
|
27102
|
+
/**
|
|
27103
|
+
* Uses `list.indexOf` to implement something like `Array.prototype.includes`,
|
|
27104
|
+
* which we can not rely on being available.
|
|
27105
|
+
*
|
|
27106
|
+
* @param {any[]} list
|
|
27107
|
+
* @returns {function(any): boolean}
|
|
27108
|
+
*/
|
|
27109
|
+
function arrayIncludes (list) {
|
|
27110
|
+
return function(element) {
|
|
27111
|
+
return list && list.indexOf(element) !== -1;
|
|
27112
|
+
}
|
|
27113
|
+
}
|
|
27114
|
+
|
|
27115
|
+
function copy(src,dest){
|
|
27116
|
+
for(var p in src){
|
|
27117
|
+
dest[p] = src[p];
|
|
27118
|
+
}
|
|
27119
|
+
}
|
|
27120
|
+
|
|
27121
|
+
/**
|
|
27122
|
+
^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));?
|
|
27123
|
+
^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));?
|
|
27124
|
+
*/
|
|
27125
|
+
function _extends(Class,Super){
|
|
27126
|
+
var pt = Class.prototype;
|
|
27127
|
+
if(!(pt instanceof Super)){
|
|
27128
|
+
function t(){};
|
|
27129
|
+
t.prototype = Super.prototype;
|
|
27130
|
+
t = new t();
|
|
27131
|
+
copy(pt,t);
|
|
27132
|
+
Class.prototype = pt = t;
|
|
27133
|
+
}
|
|
27134
|
+
if(pt.constructor != Class){
|
|
27135
|
+
if(typeof Class != 'function'){
|
|
27136
|
+
console.error("unknown Class:"+Class)
|
|
27137
|
+
}
|
|
27138
|
+
pt.constructor = Class
|
|
27139
|
+
}
|
|
27140
|
+
}
|
|
27141
|
+
|
|
27142
|
+
// Node Types
|
|
27143
|
+
var NodeType = {}
|
|
27144
|
+
var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
|
|
27145
|
+
var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
|
|
27146
|
+
var TEXT_NODE = NodeType.TEXT_NODE = 3;
|
|
27147
|
+
var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
|
|
27148
|
+
var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
|
|
27149
|
+
var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
|
|
27150
|
+
var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
|
|
27151
|
+
var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
|
|
27152
|
+
var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;
|
|
27153
|
+
var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
|
|
27154
|
+
var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
|
|
27155
|
+
var NOTATION_NODE = NodeType.NOTATION_NODE = 12;
|
|
27156
|
+
|
|
27157
|
+
// ExceptionCode
|
|
27158
|
+
var ExceptionCode = {}
|
|
27159
|
+
var ExceptionMessage = {};
|
|
27160
|
+
var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1]="Index size error"),1);
|
|
27161
|
+
var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2);
|
|
27162
|
+
var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3);
|
|
27163
|
+
var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4);
|
|
27164
|
+
var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
|
|
27165
|
+
var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6);
|
|
27166
|
+
var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7);
|
|
27167
|
+
var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8);
|
|
27168
|
+
var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9);
|
|
27169
|
+
var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10);
|
|
27170
|
+
//level2
|
|
27171
|
+
var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
|
|
27172
|
+
var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12);
|
|
27173
|
+
var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13);
|
|
27174
|
+
var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14);
|
|
27175
|
+
var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = ((ExceptionMessage[15]="Invalid access"),15);
|
|
27176
|
+
|
|
27177
|
+
/**
|
|
27178
|
+
* DOM Level 2
|
|
27179
|
+
* Object DOMException
|
|
27180
|
+
* @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
|
|
27181
|
+
* @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
|
|
27182
|
+
*/
|
|
27183
|
+
function DOMException(code, message) {
|
|
27184
|
+
if(message instanceof Error){
|
|
27185
|
+
var error = message;
|
|
27186
|
+
}else{
|
|
27187
|
+
error = this;
|
|
27188
|
+
Error.call(this, ExceptionMessage[code]);
|
|
27189
|
+
this.message = ExceptionMessage[code];
|
|
27190
|
+
if(Error.captureStackTrace) Error.captureStackTrace(this, DOMException);
|
|
27191
|
+
}
|
|
27192
|
+
error.code = code;
|
|
27193
|
+
if(message) this.message = this.message + ": " + message;
|
|
27194
|
+
return error;
|
|
27195
|
+
};
|
|
27196
|
+
DOMException.prototype = Error.prototype;
|
|
27197
|
+
copy(ExceptionCode,DOMException)
|
|
27198
|
+
|
|
27199
|
+
/**
|
|
27200
|
+
* @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177
|
|
27201
|
+
* The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live.
|
|
27202
|
+
* The items in the NodeList are accessible via an integral index, starting from 0.
|
|
27203
|
+
*/
|
|
27204
|
+
function NodeList() {
|
|
27205
|
+
};
|
|
27206
|
+
NodeList.prototype = {
|
|
27207
|
+
/**
|
|
27208
|
+
* The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.
|
|
27209
|
+
* @standard level1
|
|
27210
|
+
*/
|
|
27211
|
+
length:0,
|
|
27212
|
+
/**
|
|
27213
|
+
* 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.
|
|
27214
|
+
* @standard level1
|
|
27215
|
+
* @param index unsigned long
|
|
27216
|
+
* Index into the collection.
|
|
27217
|
+
* @return Node
|
|
27218
|
+
* The node at the indexth position in the NodeList, or null if that is not a valid index.
|
|
27219
|
+
*/
|
|
27220
|
+
item: function(index) {
|
|
27221
|
+
return this[index] || null;
|
|
27222
|
+
},
|
|
27223
|
+
toString:function(isHTML,nodeFilter){
|
|
27224
|
+
for(var buf = [], i = 0;i<this.length;i++){
|
|
27225
|
+
serializeToString(this[i],buf,isHTML,nodeFilter);
|
|
27226
|
+
}
|
|
27227
|
+
return buf.join('');
|
|
27228
|
+
}
|
|
27229
|
+
};
|
|
27230
|
+
|
|
27231
|
+
function LiveNodeList(node,refresh){
|
|
27232
|
+
this._node = node;
|
|
27233
|
+
this._refresh = refresh
|
|
27234
|
+
_updateLiveList(this);
|
|
27235
|
+
}
|
|
27236
|
+
function _updateLiveList(list){
|
|
27237
|
+
var inc = list._node._inc || list._node.ownerDocument._inc;
|
|
27238
|
+
if(list._inc != inc){
|
|
27239
|
+
var ls = list._refresh(list._node);
|
|
27240
|
+
//console.log(ls.length)
|
|
27241
|
+
__set__(list,'length',ls.length);
|
|
27242
|
+
copy(ls,list);
|
|
27243
|
+
list._inc = inc;
|
|
27244
|
+
}
|
|
27245
|
+
}
|
|
27246
|
+
LiveNodeList.prototype.item = function(i){
|
|
27247
|
+
_updateLiveList(this);
|
|
27248
|
+
return this[i];
|
|
27249
|
+
}
|
|
27250
|
+
|
|
27251
|
+
_extends(LiveNodeList,NodeList);
|
|
27252
|
+
|
|
27253
|
+
/**
|
|
27254
|
+
* Objects implementing the NamedNodeMap interface are used
|
|
27255
|
+
* to represent collections of nodes that can be accessed by name.
|
|
27256
|
+
* Note that NamedNodeMap does not inherit from NodeList;
|
|
27257
|
+
* NamedNodeMaps are not maintained in any particular order.
|
|
27258
|
+
* Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index,
|
|
27259
|
+
* but this is simply to allow convenient enumeration of the contents of a NamedNodeMap,
|
|
27260
|
+
* and does not imply that the DOM specifies an order to these Nodes.
|
|
27261
|
+
* NamedNodeMap objects in the DOM are live.
|
|
27262
|
+
* used for attributes or DocumentType entities
|
|
27263
|
+
*/
|
|
27264
|
+
function NamedNodeMap() {
|
|
27265
|
+
};
|
|
27266
|
+
|
|
27267
|
+
function _findNodeIndex(list,node){
|
|
27268
|
+
var i = list.length;
|
|
27269
|
+
while(i--){
|
|
27270
|
+
if(list[i] === node){return i}
|
|
27271
|
+
}
|
|
27272
|
+
}
|
|
27273
|
+
|
|
27274
|
+
function _addNamedNode(el,list,newAttr,oldAttr){
|
|
27275
|
+
if(oldAttr){
|
|
27276
|
+
list[_findNodeIndex(list,oldAttr)] = newAttr;
|
|
27277
|
+
}else{
|
|
27278
|
+
list[list.length++] = newAttr;
|
|
27279
|
+
}
|
|
27280
|
+
if(el){
|
|
27281
|
+
newAttr.ownerElement = el;
|
|
27282
|
+
var doc = el.ownerDocument;
|
|
27283
|
+
if(doc){
|
|
27284
|
+
oldAttr && _onRemoveAttribute(doc,el,oldAttr);
|
|
27285
|
+
_onAddAttribute(doc,el,newAttr);
|
|
27286
|
+
}
|
|
27287
|
+
}
|
|
27288
|
+
}
|
|
27289
|
+
function _removeNamedNode(el,list,attr){
|
|
27290
|
+
//console.log('remove attr:'+attr)
|
|
27291
|
+
var i = _findNodeIndex(list,attr);
|
|
27292
|
+
if(i>=0){
|
|
27293
|
+
var lastIndex = list.length-1
|
|
27294
|
+
while(i<lastIndex){
|
|
27295
|
+
list[i] = list[++i]
|
|
27296
|
+
}
|
|
27297
|
+
list.length = lastIndex;
|
|
27298
|
+
if(el){
|
|
27299
|
+
var doc = el.ownerDocument;
|
|
27300
|
+
if(doc){
|
|
27301
|
+
_onRemoveAttribute(doc,el,attr);
|
|
27302
|
+
attr.ownerElement = null;
|
|
27303
|
+
}
|
|
27304
|
+
}
|
|
27305
|
+
}else{
|
|
27306
|
+
throw DOMException(NOT_FOUND_ERR,new Error(el.tagName+'@'+attr))
|
|
27307
|
+
}
|
|
27308
|
+
}
|
|
27309
|
+
NamedNodeMap.prototype = {
|
|
27310
|
+
length:0,
|
|
27311
|
+
item:NodeList.prototype.item,
|
|
27312
|
+
getNamedItem: function(key) {
|
|
27313
|
+
// if(key.indexOf(':')>0 || key == 'xmlns'){
|
|
27314
|
+
// return null;
|
|
27315
|
+
// }
|
|
27316
|
+
//console.log()
|
|
27317
|
+
var i = this.length;
|
|
27318
|
+
while(i--){
|
|
27319
|
+
var attr = this[i];
|
|
27320
|
+
//console.log(attr.nodeName,key)
|
|
27321
|
+
if(attr.nodeName == key){
|
|
27322
|
+
return attr;
|
|
27323
|
+
}
|
|
27324
|
+
}
|
|
27325
|
+
},
|
|
27326
|
+
setNamedItem: function(attr) {
|
|
27327
|
+
var el = attr.ownerElement;
|
|
27328
|
+
if(el && el!=this._ownerElement){
|
|
27329
|
+
throw new DOMException(INUSE_ATTRIBUTE_ERR);
|
|
27330
|
+
}
|
|
27331
|
+
var oldAttr = this.getNamedItem(attr.nodeName);
|
|
27332
|
+
_addNamedNode(this._ownerElement,this,attr,oldAttr);
|
|
27333
|
+
return oldAttr;
|
|
27334
|
+
},
|
|
27335
|
+
/* returns Node */
|
|
27336
|
+
setNamedItemNS: function(attr) {// raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR
|
|
27337
|
+
var el = attr.ownerElement, oldAttr;
|
|
27338
|
+
if(el && el!=this._ownerElement){
|
|
27339
|
+
throw new DOMException(INUSE_ATTRIBUTE_ERR);
|
|
27340
|
+
}
|
|
27341
|
+
oldAttr = this.getNamedItemNS(attr.namespaceURI,attr.localName);
|
|
27342
|
+
_addNamedNode(this._ownerElement,this,attr,oldAttr);
|
|
27343
|
+
return oldAttr;
|
|
27344
|
+
},
|
|
27345
|
+
|
|
27346
|
+
/* returns Node */
|
|
27347
|
+
removeNamedItem: function(key) {
|
|
27348
|
+
var attr = this.getNamedItem(key);
|
|
27349
|
+
_removeNamedNode(this._ownerElement,this,attr);
|
|
27350
|
+
return attr;
|
|
27351
|
+
|
|
27352
|
+
|
|
27353
|
+
},// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
|
|
27354
|
+
|
|
27355
|
+
//for level2
|
|
27356
|
+
removeNamedItemNS:function(namespaceURI,localName){
|
|
27357
|
+
var attr = this.getNamedItemNS(namespaceURI,localName);
|
|
27358
|
+
_removeNamedNode(this._ownerElement,this,attr);
|
|
27359
|
+
return attr;
|
|
27360
|
+
},
|
|
27361
|
+
getNamedItemNS: function(namespaceURI, localName) {
|
|
27362
|
+
var i = this.length;
|
|
27363
|
+
while(i--){
|
|
27364
|
+
var node = this[i];
|
|
27365
|
+
if(node.localName == localName && node.namespaceURI == namespaceURI){
|
|
27366
|
+
return node;
|
|
27367
|
+
}
|
|
27368
|
+
}
|
|
27369
|
+
return null;
|
|
27370
|
+
}
|
|
27371
|
+
};
|
|
27372
|
+
|
|
27373
|
+
/**
|
|
27374
|
+
* The DOMImplementation interface represents an object providing methods
|
|
27375
|
+
* which are not dependent on any particular document.
|
|
27376
|
+
* Such an object is returned by the `Document.implementation` property.
|
|
27377
|
+
*
|
|
27378
|
+
* __The individual methods describe the differences compared to the specs.__
|
|
27379
|
+
*
|
|
27380
|
+
* @constructor
|
|
27381
|
+
*
|
|
27382
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN
|
|
27383
|
+
* @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core (Initial)
|
|
27384
|
+
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core
|
|
27385
|
+
* @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core
|
|
27386
|
+
* @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard
|
|
27387
|
+
*/
|
|
27388
|
+
function DOMImplementation() {
|
|
27389
|
+
}
|
|
27390
|
+
|
|
27391
|
+
DOMImplementation.prototype = {
|
|
27392
|
+
/**
|
|
27393
|
+
* The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given feature is supported.
|
|
27394
|
+
* The different implementations fairly diverged in what kind of features were reported.
|
|
27395
|
+
* The latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use.
|
|
27396
|
+
*
|
|
27397
|
+
* @deprecated It is deprecated and modern browsers return true in all cases.
|
|
27398
|
+
*
|
|
27399
|
+
* @param {string} feature
|
|
27400
|
+
* @param {string} [version]
|
|
27401
|
+
* @returns {boolean} always true
|
|
27402
|
+
*
|
|
27403
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN
|
|
27404
|
+
* @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core
|
|
27405
|
+
* @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard
|
|
27406
|
+
*/
|
|
27407
|
+
hasFeature: function(feature, version) {
|
|
27408
|
+
return true;
|
|
27409
|
+
},
|
|
27410
|
+
/**
|
|
27411
|
+
* Creates an XML Document object of the specified type with its document element.
|
|
27412
|
+
*
|
|
27413
|
+
* __It behaves slightly different from the description in the living standard__:
|
|
27414
|
+
* - There is no interface/class `XMLDocument`, it returns a `Document` instance.
|
|
27415
|
+
* - `contentType`, `encoding`, `mode`, `origin`, `url` fields are currently not declared.
|
|
27416
|
+
* - this implementation is not validating names or qualified names
|
|
27417
|
+
* (when parsing XML strings, the SAX parser takes care of that)
|
|
27418
|
+
*
|
|
27419
|
+
* @param {string|null} namespaceURI
|
|
27420
|
+
* @param {string} qualifiedName
|
|
27421
|
+
* @param {DocumentType=null} doctype
|
|
27422
|
+
* @returns {Document}
|
|
27423
|
+
*
|
|
27424
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN
|
|
27425
|
+
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM Level 2 Core (initial)
|
|
27426
|
+
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core
|
|
27427
|
+
*
|
|
27428
|
+
* @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
|
|
27429
|
+
* @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
|
|
27430
|
+
* @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
|
|
27431
|
+
*/
|
|
27432
|
+
createDocument: function(namespaceURI, qualifiedName, doctype){
|
|
27433
|
+
var doc = new Document();
|
|
27434
|
+
doc.implementation = this;
|
|
27435
|
+
doc.childNodes = new NodeList();
|
|
27436
|
+
doc.doctype = doctype || null;
|
|
27437
|
+
if (doctype){
|
|
27438
|
+
doc.appendChild(doctype);
|
|
27439
|
+
}
|
|
27440
|
+
if (qualifiedName){
|
|
27441
|
+
var root = doc.createElementNS(namespaceURI, qualifiedName);
|
|
27442
|
+
doc.appendChild(root);
|
|
27443
|
+
}
|
|
27444
|
+
return doc;
|
|
27445
|
+
},
|
|
27446
|
+
/**
|
|
27447
|
+
* Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.
|
|
27448
|
+
*
|
|
27449
|
+
* __This behavior is slightly different from the in the specs__:
|
|
27450
|
+
* - this implementation is not validating names or qualified names
|
|
27451
|
+
* (when parsing XML strings, the SAX parser takes care of that)
|
|
27452
|
+
*
|
|
27453
|
+
* @param {string} qualifiedName
|
|
27454
|
+
* @param {string} [publicId]
|
|
27455
|
+
* @param {string} [systemId]
|
|
27456
|
+
* @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation
|
|
27457
|
+
* or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`
|
|
27458
|
+
*
|
|
27459
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType MDN
|
|
27460
|
+
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM Level 2 Core
|
|
27461
|
+
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living Standard
|
|
27462
|
+
*
|
|
27463
|
+
* @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
|
|
27464
|
+
* @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
|
|
27465
|
+
* @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
|
|
27466
|
+
*/
|
|
27467
|
+
createDocumentType: function(qualifiedName, publicId, systemId){
|
|
27468
|
+
var node = new DocumentType();
|
|
27469
|
+
node.name = qualifiedName;
|
|
27470
|
+
node.nodeName = qualifiedName;
|
|
27471
|
+
node.publicId = publicId || '';
|
|
27472
|
+
node.systemId = systemId || '';
|
|
27473
|
+
|
|
27474
|
+
return node;
|
|
27475
|
+
}
|
|
27476
|
+
};
|
|
27477
|
+
|
|
27478
|
+
|
|
27479
|
+
/**
|
|
27480
|
+
* @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247
|
|
27481
|
+
*/
|
|
27482
|
+
|
|
27483
|
+
function Node() {
|
|
27484
|
+
};
|
|
27485
|
+
|
|
27486
|
+
Node.prototype = {
|
|
27487
|
+
firstChild : null,
|
|
27488
|
+
lastChild : null,
|
|
27489
|
+
previousSibling : null,
|
|
27490
|
+
nextSibling : null,
|
|
27491
|
+
attributes : null,
|
|
27492
|
+
parentNode : null,
|
|
27493
|
+
childNodes : null,
|
|
27494
|
+
ownerDocument : null,
|
|
27495
|
+
nodeValue : null,
|
|
27496
|
+
namespaceURI : null,
|
|
27497
|
+
prefix : null,
|
|
27498
|
+
localName : null,
|
|
27499
|
+
// Modified in DOM Level 2:
|
|
27500
|
+
insertBefore:function(newChild, refChild){//raises
|
|
27501
|
+
return _insertBefore(this,newChild,refChild);
|
|
27502
|
+
},
|
|
27503
|
+
replaceChild:function(newChild, oldChild){//raises
|
|
27504
|
+
this.insertBefore(newChild,oldChild);
|
|
27505
|
+
if(oldChild){
|
|
27506
|
+
this.removeChild(oldChild);
|
|
27507
|
+
}
|
|
27508
|
+
},
|
|
27509
|
+
removeChild:function(oldChild){
|
|
27510
|
+
return _removeChild(this,oldChild);
|
|
27511
|
+
},
|
|
27512
|
+
appendChild:function(newChild){
|
|
27513
|
+
return this.insertBefore(newChild,null);
|
|
27514
|
+
},
|
|
27515
|
+
hasChildNodes:function(){
|
|
27516
|
+
return this.firstChild != null;
|
|
27517
|
+
},
|
|
27518
|
+
cloneNode:function(deep){
|
|
27519
|
+
return cloneNode(this.ownerDocument||this,this,deep);
|
|
27520
|
+
},
|
|
27521
|
+
// Modified in DOM Level 2:
|
|
27522
|
+
normalize:function(){
|
|
27523
|
+
var child = this.firstChild;
|
|
27524
|
+
while(child){
|
|
27525
|
+
var next = child.nextSibling;
|
|
27526
|
+
if(next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE){
|
|
27527
|
+
this.removeChild(next);
|
|
27528
|
+
child.appendData(next.data);
|
|
27529
|
+
}else{
|
|
27530
|
+
child.normalize();
|
|
27531
|
+
child = next;
|
|
27532
|
+
}
|
|
27533
|
+
}
|
|
27534
|
+
},
|
|
27535
|
+
// Introduced in DOM Level 2:
|
|
27536
|
+
isSupported:function(feature, version){
|
|
27537
|
+
return this.ownerDocument.implementation.hasFeature(feature,version);
|
|
27538
|
+
},
|
|
27539
|
+
// Introduced in DOM Level 2:
|
|
27540
|
+
hasAttributes:function(){
|
|
27541
|
+
return this.attributes.length>0;
|
|
27542
|
+
},
|
|
27543
|
+
/**
|
|
27544
|
+
* Look up the prefix associated to the given namespace URI, starting from this node.
|
|
27545
|
+
* **The default namespace declarations are ignored by this method.**
|
|
27546
|
+
* See Namespace Prefix Lookup for details on the algorithm used by this method.
|
|
27547
|
+
*
|
|
27548
|
+
* _Note: The implementation seems to be incomplete when compared to the algorithm described in the specs._
|
|
27549
|
+
*
|
|
27550
|
+
* @param {string | null} namespaceURI
|
|
27551
|
+
* @returns {string | null}
|
|
27552
|
+
* @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix
|
|
27553
|
+
* @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo
|
|
27554
|
+
* @see https://dom.spec.whatwg.org/#dom-node-lookupprefix
|
|
27555
|
+
* @see https://github.com/xmldom/xmldom/issues/322
|
|
27556
|
+
*/
|
|
27557
|
+
lookupPrefix:function(namespaceURI){
|
|
27558
|
+
var el = this;
|
|
27559
|
+
while(el){
|
|
27560
|
+
var map = el._nsMap;
|
|
27561
|
+
//console.dir(map)
|
|
27562
|
+
if(map){
|
|
27563
|
+
for(var n in map){
|
|
27564
|
+
if(map[n] == namespaceURI){
|
|
27565
|
+
return n;
|
|
27566
|
+
}
|
|
27567
|
+
}
|
|
27568
|
+
}
|
|
27569
|
+
el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
|
|
27570
|
+
}
|
|
27571
|
+
return null;
|
|
27572
|
+
},
|
|
27573
|
+
// Introduced in DOM Level 3:
|
|
27574
|
+
lookupNamespaceURI:function(prefix){
|
|
27575
|
+
var el = this;
|
|
27576
|
+
while(el){
|
|
27577
|
+
var map = el._nsMap;
|
|
27578
|
+
//console.dir(map)
|
|
27579
|
+
if(map){
|
|
27580
|
+
if(prefix in map){
|
|
27581
|
+
return map[prefix] ;
|
|
27582
|
+
}
|
|
27583
|
+
}
|
|
27584
|
+
el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
|
|
27585
|
+
}
|
|
27586
|
+
return null;
|
|
27587
|
+
},
|
|
27588
|
+
// Introduced in DOM Level 3:
|
|
27589
|
+
isDefaultNamespace:function(namespaceURI){
|
|
27590
|
+
var prefix = this.lookupPrefix(namespaceURI);
|
|
27591
|
+
return prefix == null;
|
|
27592
|
+
}
|
|
27593
|
+
};
|
|
27594
|
+
|
|
27595
|
+
|
|
27596
|
+
function _xmlEncoder(c){
|
|
27597
|
+
return c == '<' && '<' ||
|
|
27598
|
+
c == '>' && '>' ||
|
|
27599
|
+
c == '&' && '&' ||
|
|
27600
|
+
c == '"' && '"' ||
|
|
27601
|
+
'&#'+c.charCodeAt()+';'
|
|
27602
|
+
}
|
|
27603
|
+
|
|
27604
|
+
|
|
27605
|
+
copy(NodeType,Node);
|
|
27606
|
+
copy(NodeType,Node.prototype);
|
|
27607
|
+
|
|
27608
|
+
/**
|
|
27609
|
+
* @param callback return true for continue,false for break
|
|
27610
|
+
* @return boolean true: break visit;
|
|
27611
|
+
*/
|
|
27612
|
+
function _visitNode(node,callback){
|
|
27613
|
+
if(callback(node)){
|
|
27614
|
+
return true;
|
|
27615
|
+
}
|
|
27616
|
+
if(node = node.firstChild){
|
|
27617
|
+
do{
|
|
27618
|
+
if(_visitNode(node,callback)){return true}
|
|
27619
|
+
}while(node=node.nextSibling)
|
|
27620
|
+
}
|
|
27621
|
+
}
|
|
27622
|
+
|
|
27623
|
+
|
|
27624
|
+
|
|
27625
|
+
function Document(){
|
|
27626
|
+
}
|
|
27627
|
+
|
|
27628
|
+
function _onAddAttribute(doc,el,newAttr){
|
|
27629
|
+
doc && doc._inc++;
|
|
27630
|
+
var ns = newAttr.namespaceURI ;
|
|
27631
|
+
if(ns === NAMESPACE.XMLNS){
|
|
27632
|
+
//update namespace
|
|
27633
|
+
el._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value
|
|
27634
|
+
}
|
|
27635
|
+
}
|
|
27636
|
+
|
|
27637
|
+
function _onRemoveAttribute(doc,el,newAttr,remove){
|
|
27638
|
+
doc && doc._inc++;
|
|
27639
|
+
var ns = newAttr.namespaceURI ;
|
|
27640
|
+
if(ns === NAMESPACE.XMLNS){
|
|
27641
|
+
//update namespace
|
|
27642
|
+
delete el._nsMap[newAttr.prefix?newAttr.localName:'']
|
|
27643
|
+
}
|
|
27644
|
+
}
|
|
27645
|
+
|
|
27646
|
+
/**
|
|
27647
|
+
* Updates `el.childNodes`, updating the indexed items and it's `length`.
|
|
27648
|
+
* Passing `newChild` means it will be appended.
|
|
27649
|
+
* Otherwise it's assumed that an item has been removed,
|
|
27650
|
+
* and `el.firstNode` and it's `.nextSibling` are used
|
|
27651
|
+
* to walk the current list of child nodes.
|
|
27652
|
+
*
|
|
27653
|
+
* @param {Document} doc
|
|
27654
|
+
* @param {Node} el
|
|
27655
|
+
* @param {Node} [newChild]
|
|
27656
|
+
* @private
|
|
27657
|
+
*/
|
|
27658
|
+
function _onUpdateChild (doc, el, newChild) {
|
|
27659
|
+
if(doc && doc._inc){
|
|
27660
|
+
doc._inc++;
|
|
27661
|
+
//update childNodes
|
|
27662
|
+
var cs = el.childNodes;
|
|
27663
|
+
if (newChild) {
|
|
27664
|
+
cs[cs.length++] = newChild;
|
|
27665
|
+
} else {
|
|
27666
|
+
var child = el.firstChild;
|
|
27667
|
+
var i = 0;
|
|
27668
|
+
while (child) {
|
|
27669
|
+
cs[i++] = child;
|
|
27670
|
+
child = child.nextSibling;
|
|
27671
|
+
}
|
|
27672
|
+
cs.length = i;
|
|
27673
|
+
delete cs[cs.length];
|
|
27674
|
+
}
|
|
27675
|
+
}
|
|
27676
|
+
}
|
|
27677
|
+
|
|
27678
|
+
/**
|
|
27679
|
+
* Removes the connections between `parentNode` and `child`
|
|
27680
|
+
* and any existing `child.previousSibling` or `child.nextSibling`.
|
|
27681
|
+
*
|
|
27682
|
+
* @see https://github.com/xmldom/xmldom/issues/135
|
|
27683
|
+
* @see https://github.com/xmldom/xmldom/issues/145
|
|
27684
|
+
*
|
|
27685
|
+
* @param {Node} parentNode
|
|
27686
|
+
* @param {Node} child
|
|
27687
|
+
* @returns {Node} the child that was removed.
|
|
27688
|
+
* @private
|
|
27689
|
+
*/
|
|
27690
|
+
function _removeChild (parentNode, child) {
|
|
27691
|
+
var previous = child.previousSibling;
|
|
27692
|
+
var next = child.nextSibling;
|
|
27693
|
+
if (previous) {
|
|
27694
|
+
previous.nextSibling = next;
|
|
27695
|
+
} else {
|
|
27696
|
+
parentNode.firstChild = next;
|
|
27697
|
+
}
|
|
27698
|
+
if (next) {
|
|
27699
|
+
next.previousSibling = previous;
|
|
27700
|
+
} else {
|
|
27701
|
+
parentNode.lastChild = previous;
|
|
27702
|
+
}
|
|
27703
|
+
child.parentNode = null;
|
|
27704
|
+
child.previousSibling = null;
|
|
27705
|
+
child.nextSibling = null;
|
|
27706
|
+
_onUpdateChild(parentNode.ownerDocument, parentNode);
|
|
27707
|
+
return child;
|
|
27708
|
+
}
|
|
27709
|
+
/**
|
|
27710
|
+
* preformance key(refChild == null)
|
|
27711
|
+
*/
|
|
27712
|
+
function _insertBefore(parentNode,newChild,nextChild){
|
|
27713
|
+
var cp = newChild.parentNode;
|
|
27714
|
+
if(cp){
|
|
27715
|
+
cp.removeChild(newChild);//remove and update
|
|
27716
|
+
}
|
|
27717
|
+
if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
|
|
27718
|
+
var newFirst = newChild.firstChild;
|
|
27719
|
+
if (newFirst == null) {
|
|
27720
|
+
return newChild;
|
|
27721
|
+
}
|
|
27722
|
+
var newLast = newChild.lastChild;
|
|
27723
|
+
}else{
|
|
27724
|
+
newFirst = newLast = newChild;
|
|
27725
|
+
}
|
|
27726
|
+
var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild;
|
|
27727
|
+
|
|
27728
|
+
newFirst.previousSibling = pre;
|
|
27729
|
+
newLast.nextSibling = nextChild;
|
|
27730
|
+
|
|
27731
|
+
|
|
27732
|
+
if(pre){
|
|
27733
|
+
pre.nextSibling = newFirst;
|
|
27734
|
+
}else{
|
|
27735
|
+
parentNode.firstChild = newFirst;
|
|
27736
|
+
}
|
|
27737
|
+
if(nextChild == null){
|
|
27738
|
+
parentNode.lastChild = newLast;
|
|
27739
|
+
}else{
|
|
27740
|
+
nextChild.previousSibling = newLast;
|
|
27741
|
+
}
|
|
27742
|
+
do{
|
|
27743
|
+
newFirst.parentNode = parentNode;
|
|
27744
|
+
}while(newFirst !== newLast && (newFirst= newFirst.nextSibling))
|
|
27745
|
+
_onUpdateChild(parentNode.ownerDocument||parentNode,parentNode);
|
|
27746
|
+
//console.log(parentNode.lastChild.nextSibling == null)
|
|
27747
|
+
if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
|
|
27748
|
+
newChild.firstChild = newChild.lastChild = null;
|
|
27749
|
+
}
|
|
27750
|
+
return newChild;
|
|
27751
|
+
}
|
|
27752
|
+
|
|
27753
|
+
/**
|
|
27754
|
+
* Appends `newChild` to `parentNode`.
|
|
27755
|
+
* If `newChild` is already connected to a `parentNode` it is first removed from it.
|
|
27756
|
+
*
|
|
27757
|
+
* @see https://github.com/xmldom/xmldom/issues/135
|
|
27758
|
+
* @see https://github.com/xmldom/xmldom/issues/145
|
|
27759
|
+
* @param {Node} parentNode
|
|
27760
|
+
* @param {Node} newChild
|
|
27761
|
+
* @returns {Node}
|
|
27762
|
+
* @private
|
|
27763
|
+
*/
|
|
27764
|
+
function _appendSingleChild (parentNode, newChild) {
|
|
27765
|
+
if (newChild.parentNode) {
|
|
27766
|
+
newChild.parentNode.removeChild(newChild);
|
|
27767
|
+
}
|
|
27768
|
+
newChild.parentNode = parentNode;
|
|
27769
|
+
newChild.previousSibling = parentNode.lastChild;
|
|
27770
|
+
newChild.nextSibling = null;
|
|
27771
|
+
if (newChild.previousSibling) {
|
|
27772
|
+
newChild.previousSibling.nextSibling = newChild;
|
|
27773
|
+
} else {
|
|
27774
|
+
parentNode.firstChild = newChild;
|
|
27775
|
+
}
|
|
27776
|
+
parentNode.lastChild = newChild;
|
|
27777
|
+
_onUpdateChild(parentNode.ownerDocument, parentNode, newChild);
|
|
27778
|
+
return newChild;
|
|
27779
|
+
}
|
|
27780
|
+
|
|
27781
|
+
Document.prototype = {
|
|
27782
|
+
//implementation : null,
|
|
27783
|
+
nodeName : '#document',
|
|
27784
|
+
nodeType : DOCUMENT_NODE,
|
|
27785
|
+
/**
|
|
27786
|
+
* The DocumentType node of the document.
|
|
27787
|
+
*
|
|
27788
|
+
* @readonly
|
|
27789
|
+
* @type DocumentType
|
|
27790
|
+
*/
|
|
27791
|
+
doctype : null,
|
|
27792
|
+
documentElement : null,
|
|
27793
|
+
_inc : 1,
|
|
27794
|
+
|
|
27795
|
+
insertBefore : function(newChild, refChild){//raises
|
|
27796
|
+
if(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){
|
|
27797
|
+
var child = newChild.firstChild;
|
|
27798
|
+
while(child){
|
|
27799
|
+
var next = child.nextSibling;
|
|
27800
|
+
this.insertBefore(child,refChild);
|
|
27801
|
+
child = next;
|
|
27802
|
+
}
|
|
27803
|
+
return newChild;
|
|
27804
|
+
}
|
|
27805
|
+
if(this.documentElement == null && newChild.nodeType == ELEMENT_NODE){
|
|
27806
|
+
this.documentElement = newChild;
|
|
27807
|
+
}
|
|
27808
|
+
|
|
27809
|
+
return _insertBefore(this,newChild,refChild),(newChild.ownerDocument = this),newChild;
|
|
27810
|
+
},
|
|
27811
|
+
removeChild : function(oldChild){
|
|
27812
|
+
if(this.documentElement == oldChild){
|
|
27813
|
+
this.documentElement = null;
|
|
27814
|
+
}
|
|
27815
|
+
return _removeChild(this,oldChild);
|
|
27816
|
+
},
|
|
27817
|
+
// Introduced in DOM Level 2:
|
|
27818
|
+
importNode : function(importedNode,deep){
|
|
27819
|
+
return importNode(this,importedNode,deep);
|
|
27820
|
+
},
|
|
27821
|
+
// Introduced in DOM Level 2:
|
|
27822
|
+
getElementById : function(id){
|
|
27823
|
+
var rtv = null;
|
|
27824
|
+
_visitNode(this.documentElement,function(node){
|
|
27825
|
+
if(node.nodeType == ELEMENT_NODE){
|
|
27826
|
+
if(node.getAttribute('id') == id){
|
|
27827
|
+
rtv = node;
|
|
27828
|
+
return true;
|
|
27829
|
+
}
|
|
27830
|
+
}
|
|
27831
|
+
})
|
|
27832
|
+
return rtv;
|
|
27833
|
+
},
|
|
27834
|
+
|
|
27835
|
+
/**
|
|
27836
|
+
* The `getElementsByClassName` method of `Document` interface returns an array-like object
|
|
27837
|
+
* of all child elements which have **all** of the given class name(s).
|
|
27838
|
+
*
|
|
27839
|
+
* Returns an empty list if `classeNames` is an empty string or only contains HTML white space characters.
|
|
27840
|
+
*
|
|
27841
|
+
*
|
|
27842
|
+
* Warning: This is a live LiveNodeList.
|
|
27843
|
+
* Changes in the DOM will reflect in the array as the changes occur.
|
|
27844
|
+
* If an element selected by this array no longer qualifies for the selector,
|
|
27845
|
+
* it will automatically be removed. Be aware of this for iteration purposes.
|
|
27846
|
+
*
|
|
27847
|
+
* @param {string} classNames is a string representing the class name(s) to match; multiple class names are separated by (ASCII-)whitespace
|
|
27848
|
+
*
|
|
27849
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
|
|
27850
|
+
* @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
|
|
27851
|
+
*/
|
|
27852
|
+
getElementsByClassName: function(classNames) {
|
|
27853
|
+
var classNamesSet = toOrderedSet(classNames)
|
|
27854
|
+
return new LiveNodeList(this, function(base) {
|
|
27855
|
+
var ls = [];
|
|
27856
|
+
if (classNamesSet.length > 0) {
|
|
27857
|
+
_visitNode(base.documentElement, function(node) {
|
|
27858
|
+
if(node !== base && node.nodeType === ELEMENT_NODE) {
|
|
27859
|
+
var nodeClassNames = node.getAttribute('class')
|
|
27860
|
+
// can be null if the attribute does not exist
|
|
27861
|
+
if (nodeClassNames) {
|
|
27862
|
+
// before splitting and iterating just compare them for the most common case
|
|
27863
|
+
var matches = classNames === nodeClassNames;
|
|
27864
|
+
if (!matches) {
|
|
27865
|
+
var nodeClassNamesSet = toOrderedSet(nodeClassNames)
|
|
27866
|
+
matches = classNamesSet.every(arrayIncludes(nodeClassNamesSet))
|
|
27867
|
+
}
|
|
27868
|
+
if(matches) {
|
|
27869
|
+
ls.push(node);
|
|
27870
|
+
}
|
|
27871
|
+
}
|
|
27872
|
+
}
|
|
27873
|
+
});
|
|
27874
|
+
}
|
|
27875
|
+
return ls;
|
|
27876
|
+
});
|
|
27877
|
+
},
|
|
27878
|
+
|
|
27879
|
+
//document factory method:
|
|
27880
|
+
createElement : function(tagName){
|
|
27881
|
+
var node = new Element();
|
|
27882
|
+
node.ownerDocument = this;
|
|
27883
|
+
node.nodeName = tagName;
|
|
27884
|
+
node.tagName = tagName;
|
|
27885
|
+
node.localName = tagName;
|
|
27886
|
+
node.childNodes = new NodeList();
|
|
27887
|
+
var attrs = node.attributes = new NamedNodeMap();
|
|
27888
|
+
attrs._ownerElement = node;
|
|
27889
|
+
return node;
|
|
27890
|
+
},
|
|
27891
|
+
createDocumentFragment : function(){
|
|
27892
|
+
var node = new DocumentFragment();
|
|
27893
|
+
node.ownerDocument = this;
|
|
27894
|
+
node.childNodes = new NodeList();
|
|
27895
|
+
return node;
|
|
27896
|
+
},
|
|
27897
|
+
createTextNode : function(data){
|
|
27898
|
+
var node = new Text();
|
|
27899
|
+
node.ownerDocument = this;
|
|
27900
|
+
node.appendData(data)
|
|
27901
|
+
return node;
|
|
27902
|
+
},
|
|
27903
|
+
createComment : function(data){
|
|
27904
|
+
var node = new Comment();
|
|
27905
|
+
node.ownerDocument = this;
|
|
27906
|
+
node.appendData(data)
|
|
27907
|
+
return node;
|
|
27908
|
+
},
|
|
27909
|
+
createCDATASection : function(data){
|
|
27910
|
+
var node = new CDATASection();
|
|
27911
|
+
node.ownerDocument = this;
|
|
27912
|
+
node.appendData(data)
|
|
27913
|
+
return node;
|
|
27914
|
+
},
|
|
27915
|
+
createProcessingInstruction : function(target,data){
|
|
27916
|
+
var node = new ProcessingInstruction();
|
|
27917
|
+
node.ownerDocument = this;
|
|
27918
|
+
node.tagName = node.target = target;
|
|
27919
|
+
node.nodeValue= node.data = data;
|
|
27920
|
+
return node;
|
|
27921
|
+
},
|
|
27922
|
+
createAttribute : function(name){
|
|
27923
|
+
var node = new Attr();
|
|
27924
|
+
node.ownerDocument = this;
|
|
27925
|
+
node.name = name;
|
|
27926
|
+
node.nodeName = name;
|
|
27927
|
+
node.localName = name;
|
|
27928
|
+
node.specified = true;
|
|
27929
|
+
return node;
|
|
27930
|
+
},
|
|
27931
|
+
createEntityReference : function(name){
|
|
27932
|
+
var node = new EntityReference();
|
|
27933
|
+
node.ownerDocument = this;
|
|
27934
|
+
node.nodeName = name;
|
|
27935
|
+
return node;
|
|
27936
|
+
},
|
|
27937
|
+
// Introduced in DOM Level 2:
|
|
27938
|
+
createElementNS : function(namespaceURI,qualifiedName){
|
|
27939
|
+
var node = new Element();
|
|
27940
|
+
var pl = qualifiedName.split(':');
|
|
27941
|
+
var attrs = node.attributes = new NamedNodeMap();
|
|
27942
|
+
node.childNodes = new NodeList();
|
|
27943
|
+
node.ownerDocument = this;
|
|
27944
|
+
node.nodeName = qualifiedName;
|
|
27945
|
+
node.tagName = qualifiedName;
|
|
27946
|
+
node.namespaceURI = namespaceURI;
|
|
27947
|
+
if(pl.length == 2){
|
|
27948
|
+
node.prefix = pl[0];
|
|
27949
|
+
node.localName = pl[1];
|
|
27950
|
+
}else{
|
|
27951
|
+
//el.prefix = null;
|
|
27952
|
+
node.localName = qualifiedName;
|
|
27953
|
+
}
|
|
27954
|
+
attrs._ownerElement = node;
|
|
27955
|
+
return node;
|
|
27956
|
+
},
|
|
27957
|
+
// Introduced in DOM Level 2:
|
|
27958
|
+
createAttributeNS : function(namespaceURI,qualifiedName){
|
|
27959
|
+
var node = new Attr();
|
|
27960
|
+
var pl = qualifiedName.split(':');
|
|
27961
|
+
node.ownerDocument = this;
|
|
27962
|
+
node.nodeName = qualifiedName;
|
|
27963
|
+
node.name = qualifiedName;
|
|
27964
|
+
node.namespaceURI = namespaceURI;
|
|
27965
|
+
node.specified = true;
|
|
27966
|
+
if(pl.length == 2){
|
|
27967
|
+
node.prefix = pl[0];
|
|
27968
|
+
node.localName = pl[1];
|
|
27969
|
+
}else{
|
|
27970
|
+
//el.prefix = null;
|
|
27971
|
+
node.localName = qualifiedName;
|
|
27972
|
+
}
|
|
27973
|
+
return node;
|
|
27974
|
+
}
|
|
27975
|
+
};
|
|
27976
|
+
_extends(Document,Node);
|
|
27977
|
+
|
|
27978
|
+
|
|
27979
|
+
function Element() {
|
|
27980
|
+
this._nsMap = {};
|
|
27981
|
+
};
|
|
27982
|
+
Element.prototype = {
|
|
27983
|
+
nodeType : ELEMENT_NODE,
|
|
27984
|
+
hasAttribute : function(name){
|
|
27985
|
+
return this.getAttributeNode(name)!=null;
|
|
27986
|
+
},
|
|
27987
|
+
getAttribute : function(name){
|
|
27988
|
+
var attr = this.getAttributeNode(name);
|
|
27989
|
+
return attr && attr.value || '';
|
|
27990
|
+
},
|
|
27991
|
+
getAttributeNode : function(name){
|
|
27992
|
+
return this.attributes.getNamedItem(name);
|
|
27993
|
+
},
|
|
27994
|
+
setAttribute : function(name, value){
|
|
27995
|
+
var attr = this.ownerDocument.createAttribute(name);
|
|
27996
|
+
attr.value = attr.nodeValue = "" + value;
|
|
27997
|
+
this.setAttributeNode(attr)
|
|
27998
|
+
},
|
|
27999
|
+
removeAttribute : function(name){
|
|
28000
|
+
var attr = this.getAttributeNode(name)
|
|
28001
|
+
attr && this.removeAttributeNode(attr);
|
|
28002
|
+
},
|
|
28003
|
+
|
|
28004
|
+
//four real opeartion method
|
|
28005
|
+
appendChild:function(newChild){
|
|
28006
|
+
if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
|
|
28007
|
+
return this.insertBefore(newChild,null);
|
|
28008
|
+
}else{
|
|
28009
|
+
return _appendSingleChild(this,newChild);
|
|
28010
|
+
}
|
|
28011
|
+
},
|
|
28012
|
+
setAttributeNode : function(newAttr){
|
|
28013
|
+
return this.attributes.setNamedItem(newAttr);
|
|
28014
|
+
},
|
|
28015
|
+
setAttributeNodeNS : function(newAttr){
|
|
28016
|
+
return this.attributes.setNamedItemNS(newAttr);
|
|
28017
|
+
},
|
|
28018
|
+
removeAttributeNode : function(oldAttr){
|
|
28019
|
+
//console.log(this == oldAttr.ownerElement)
|
|
28020
|
+
return this.attributes.removeNamedItem(oldAttr.nodeName);
|
|
28021
|
+
},
|
|
28022
|
+
//get real attribute name,and remove it by removeAttributeNode
|
|
28023
|
+
removeAttributeNS : function(namespaceURI, localName){
|
|
28024
|
+
var old = this.getAttributeNodeNS(namespaceURI, localName);
|
|
28025
|
+
old && this.removeAttributeNode(old);
|
|
28026
|
+
},
|
|
28027
|
+
|
|
28028
|
+
hasAttributeNS : function(namespaceURI, localName){
|
|
28029
|
+
return this.getAttributeNodeNS(namespaceURI, localName)!=null;
|
|
28030
|
+
},
|
|
28031
|
+
getAttributeNS : function(namespaceURI, localName){
|
|
28032
|
+
var attr = this.getAttributeNodeNS(namespaceURI, localName);
|
|
28033
|
+
return attr && attr.value || '';
|
|
28034
|
+
},
|
|
28035
|
+
setAttributeNS : function(namespaceURI, qualifiedName, value){
|
|
28036
|
+
var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
|
|
28037
|
+
attr.value = attr.nodeValue = "" + value;
|
|
28038
|
+
this.setAttributeNode(attr)
|
|
28039
|
+
},
|
|
28040
|
+
getAttributeNodeNS : function(namespaceURI, localName){
|
|
28041
|
+
return this.attributes.getNamedItemNS(namespaceURI, localName);
|
|
28042
|
+
},
|
|
28043
|
+
|
|
28044
|
+
getElementsByTagName : function(tagName){
|
|
28045
|
+
return new LiveNodeList(this,function(base){
|
|
28046
|
+
var ls = [];
|
|
28047
|
+
_visitNode(base,function(node){
|
|
28048
|
+
if(node !== base && node.nodeType == ELEMENT_NODE && (tagName === '*' || node.tagName == tagName)){
|
|
28049
|
+
ls.push(node);
|
|
28050
|
+
}
|
|
28051
|
+
});
|
|
28052
|
+
return ls;
|
|
28053
|
+
});
|
|
28054
|
+
},
|
|
28055
|
+
getElementsByTagNameNS : function(namespaceURI, localName){
|
|
28056
|
+
return new LiveNodeList(this,function(base){
|
|
28057
|
+
var ls = [];
|
|
28058
|
+
_visitNode(base,function(node){
|
|
28059
|
+
if(node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === '*' || node.namespaceURI === namespaceURI) && (localName === '*' || node.localName == localName)){
|
|
28060
|
+
ls.push(node);
|
|
28061
|
+
}
|
|
28062
|
+
});
|
|
28063
|
+
return ls;
|
|
28064
|
+
|
|
28065
|
+
});
|
|
28066
|
+
}
|
|
28067
|
+
};
|
|
28068
|
+
Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
|
|
28069
|
+
Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
|
|
28070
|
+
|
|
28071
|
+
|
|
28072
|
+
_extends(Element,Node);
|
|
28073
|
+
function Attr() {
|
|
28074
|
+
};
|
|
28075
|
+
Attr.prototype.nodeType = ATTRIBUTE_NODE;
|
|
28076
|
+
_extends(Attr,Node);
|
|
28077
|
+
|
|
28078
|
+
|
|
28079
|
+
function CharacterData() {
|
|
28080
|
+
};
|
|
28081
|
+
CharacterData.prototype = {
|
|
28082
|
+
data : '',
|
|
28083
|
+
substringData : function(offset, count) {
|
|
28084
|
+
return this.data.substring(offset, offset+count);
|
|
28085
|
+
},
|
|
28086
|
+
appendData: function(text) {
|
|
28087
|
+
text = this.data+text;
|
|
28088
|
+
this.nodeValue = this.data = text;
|
|
28089
|
+
this.length = text.length;
|
|
28090
|
+
},
|
|
28091
|
+
insertData: function(offset,text) {
|
|
28092
|
+
this.replaceData(offset,0,text);
|
|
28093
|
+
|
|
28094
|
+
},
|
|
28095
|
+
appendChild:function(newChild){
|
|
28096
|
+
throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR])
|
|
28097
|
+
},
|
|
28098
|
+
deleteData: function(offset, count) {
|
|
28099
|
+
this.replaceData(offset,count,"");
|
|
28100
|
+
},
|
|
28101
|
+
replaceData: function(offset, count, text) {
|
|
28102
|
+
var start = this.data.substring(0,offset);
|
|
28103
|
+
var end = this.data.substring(offset+count);
|
|
28104
|
+
text = start + text + end;
|
|
28105
|
+
this.nodeValue = this.data = text;
|
|
28106
|
+
this.length = text.length;
|
|
28107
|
+
}
|
|
28108
|
+
}
|
|
28109
|
+
_extends(CharacterData,Node);
|
|
28110
|
+
function Text() {
|
|
28111
|
+
};
|
|
28112
|
+
Text.prototype = {
|
|
28113
|
+
nodeName : "#text",
|
|
28114
|
+
nodeType : TEXT_NODE,
|
|
28115
|
+
splitText : function(offset) {
|
|
28116
|
+
var text = this.data;
|
|
28117
|
+
var newText = text.substring(offset);
|
|
28118
|
+
text = text.substring(0, offset);
|
|
28119
|
+
this.data = this.nodeValue = text;
|
|
28120
|
+
this.length = text.length;
|
|
28121
|
+
var newNode = this.ownerDocument.createTextNode(newText);
|
|
28122
|
+
if(this.parentNode){
|
|
28123
|
+
this.parentNode.insertBefore(newNode, this.nextSibling);
|
|
28124
|
+
}
|
|
28125
|
+
return newNode;
|
|
28126
|
+
}
|
|
28127
|
+
}
|
|
28128
|
+
_extends(Text,CharacterData);
|
|
28129
|
+
function Comment() {
|
|
28130
|
+
};
|
|
28131
|
+
Comment.prototype = {
|
|
28132
|
+
nodeName : "#comment",
|
|
28133
|
+
nodeType : COMMENT_NODE
|
|
28134
|
+
}
|
|
28135
|
+
_extends(Comment,CharacterData);
|
|
28136
|
+
|
|
28137
|
+
function CDATASection() {
|
|
28138
|
+
};
|
|
28139
|
+
CDATASection.prototype = {
|
|
28140
|
+
nodeName : "#cdata-section",
|
|
28141
|
+
nodeType : CDATA_SECTION_NODE
|
|
28142
|
+
}
|
|
28143
|
+
_extends(CDATASection,CharacterData);
|
|
28144
|
+
|
|
28145
|
+
|
|
28146
|
+
function DocumentType() {
|
|
28147
|
+
};
|
|
28148
|
+
DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
|
|
28149
|
+
_extends(DocumentType,Node);
|
|
28150
|
+
|
|
28151
|
+
function Notation() {
|
|
28152
|
+
};
|
|
28153
|
+
Notation.prototype.nodeType = NOTATION_NODE;
|
|
28154
|
+
_extends(Notation,Node);
|
|
28155
|
+
|
|
28156
|
+
function Entity() {
|
|
28157
|
+
};
|
|
28158
|
+
Entity.prototype.nodeType = ENTITY_NODE;
|
|
28159
|
+
_extends(Entity,Node);
|
|
28160
|
+
|
|
28161
|
+
function EntityReference() {
|
|
28162
|
+
};
|
|
28163
|
+
EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
|
|
28164
|
+
_extends(EntityReference,Node);
|
|
28165
|
+
|
|
28166
|
+
function DocumentFragment() {
|
|
28167
|
+
};
|
|
28168
|
+
DocumentFragment.prototype.nodeName = "#document-fragment";
|
|
28169
|
+
DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
|
|
28170
|
+
_extends(DocumentFragment,Node);
|
|
28171
|
+
|
|
28172
|
+
|
|
28173
|
+
function ProcessingInstruction() {
|
|
28174
|
+
}
|
|
28175
|
+
ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
|
|
28176
|
+
_extends(ProcessingInstruction,Node);
|
|
28177
|
+
function XMLSerializer(){}
|
|
28178
|
+
XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter){
|
|
28179
|
+
return nodeSerializeToString.call(node,isHtml,nodeFilter);
|
|
28180
|
+
}
|
|
28181
|
+
Node.prototype.toString = nodeSerializeToString;
|
|
28182
|
+
function nodeSerializeToString(isHtml,nodeFilter){
|
|
28183
|
+
var buf = [];
|
|
28184
|
+
var refNode = this.nodeType == 9 && this.documentElement || this;
|
|
28185
|
+
var prefix = refNode.prefix;
|
|
28186
|
+
var uri = refNode.namespaceURI;
|
|
28187
|
+
|
|
28188
|
+
if(uri && prefix == null){
|
|
28189
|
+
//console.log(prefix)
|
|
28190
|
+
var prefix = refNode.lookupPrefix(uri);
|
|
28191
|
+
if(prefix == null){
|
|
28192
|
+
//isHTML = true;
|
|
28193
|
+
var visibleNamespaces=[
|
|
28194
|
+
{namespace:uri,prefix:null}
|
|
28195
|
+
//{namespace:uri,prefix:''}
|
|
28196
|
+
]
|
|
28197
|
+
}
|
|
28198
|
+
}
|
|
28199
|
+
serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces);
|
|
28200
|
+
//console.log('###',this.nodeType,uri,prefix,buf.join(''))
|
|
28201
|
+
return buf.join('');
|
|
28202
|
+
}
|
|
28203
|
+
|
|
28204
|
+
function needNamespaceDefine(node, isHTML, visibleNamespaces) {
|
|
28205
|
+
var prefix = node.prefix || '';
|
|
28206
|
+
var uri = node.namespaceURI;
|
|
28207
|
+
// According to [Namespaces in XML 1.0](https://www.w3.org/TR/REC-xml-names/#ns-using) ,
|
|
28208
|
+
// and more specifically https://www.w3.org/TR/REC-xml-names/#nsc-NoPrefixUndecl :
|
|
28209
|
+
// > In a namespace declaration for a prefix [...], the attribute value MUST NOT be empty.
|
|
28210
|
+
// in a similar manner [Namespaces in XML 1.1](https://www.w3.org/TR/xml-names11/#ns-using)
|
|
28211
|
+
// and more specifically https://www.w3.org/TR/xml-names11/#nsc-NSDeclared :
|
|
28212
|
+
// > [...] Furthermore, the attribute value [...] must not be an empty string.
|
|
28213
|
+
// so serializing empty namespace value like xmlns:ds="" would produce an invalid XML document.
|
|
28214
|
+
if (!uri) {
|
|
28215
|
+
return false;
|
|
28216
|
+
}
|
|
28217
|
+
if (prefix === "xml" && uri === NAMESPACE.XML || uri === NAMESPACE.XMLNS) {
|
|
28218
|
+
return false;
|
|
28219
|
+
}
|
|
28220
|
+
|
|
28221
|
+
var i = visibleNamespaces.length
|
|
28222
|
+
while (i--) {
|
|
28223
|
+
var ns = visibleNamespaces[i];
|
|
28224
|
+
// get namespace prefix
|
|
28225
|
+
if (ns.prefix === prefix) {
|
|
28226
|
+
return ns.namespace !== uri;
|
|
28227
|
+
}
|
|
28228
|
+
}
|
|
28229
|
+
return true;
|
|
28230
|
+
}
|
|
28231
|
+
/**
|
|
28232
|
+
* Well-formed constraint: No < in Attribute Values
|
|
28233
|
+
* > The replacement text of any entity referred to directly or indirectly
|
|
28234
|
+
* > in an attribute value must not contain a <.
|
|
28235
|
+
* @see https://www.w3.org/TR/xml11/#CleanAttrVals
|
|
28236
|
+
* @see https://www.w3.org/TR/xml11/#NT-AttValue
|
|
28237
|
+
*
|
|
28238
|
+
* Literal whitespace other than space that appear in attribute values
|
|
28239
|
+
* are serialized as their entity references, so they will be preserved.
|
|
28240
|
+
* (In contrast to whitespace literals in the input which are normalized to spaces)
|
|
28241
|
+
* @see https://www.w3.org/TR/xml11/#AVNormalize
|
|
28242
|
+
*/
|
|
28243
|
+
function addSerializedAttribute(buf, qualifiedName, value) {
|
|
28244
|
+
buf.push(' ', qualifiedName, '="', value.replace(/[<&"\t\n\r]/g, _xmlEncoder), '"')
|
|
28245
|
+
}
|
|
28246
|
+
|
|
28247
|
+
function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
|
|
28248
|
+
if (!visibleNamespaces) {
|
|
28249
|
+
visibleNamespaces = [];
|
|
28250
|
+
}
|
|
28251
|
+
|
|
28252
|
+
if(nodeFilter){
|
|
28253
|
+
node = nodeFilter(node);
|
|
28254
|
+
if(node){
|
|
28255
|
+
if(typeof node == 'string'){
|
|
28256
|
+
buf.push(node);
|
|
28257
|
+
return;
|
|
28258
|
+
}
|
|
28259
|
+
}else{
|
|
28260
|
+
return;
|
|
28261
|
+
}
|
|
28262
|
+
//buf.sort.apply(attrs, attributeSorter);
|
|
28263
|
+
}
|
|
28264
|
+
|
|
28265
|
+
switch(node.nodeType){
|
|
28266
|
+
case ELEMENT_NODE:
|
|
28267
|
+
var attrs = node.attributes;
|
|
28268
|
+
var len = attrs.length;
|
|
28269
|
+
var child = node.firstChild;
|
|
28270
|
+
var nodeName = node.tagName;
|
|
28271
|
+
|
|
28272
|
+
isHTML = NAMESPACE.isHTML(node.namespaceURI) || isHTML
|
|
28273
|
+
|
|
28274
|
+
var prefixedNodeName = nodeName
|
|
28275
|
+
if (!isHTML && !node.prefix && node.namespaceURI) {
|
|
28276
|
+
var defaultNS
|
|
28277
|
+
// lookup current default ns from `xmlns` attribute
|
|
28278
|
+
for (var ai = 0; ai < attrs.length; ai++) {
|
|
28279
|
+
if (attrs.item(ai).name === 'xmlns') {
|
|
28280
|
+
defaultNS = attrs.item(ai).value
|
|
28281
|
+
break
|
|
28282
|
+
}
|
|
28283
|
+
}
|
|
28284
|
+
if (!defaultNS) {
|
|
28285
|
+
// lookup current default ns in visibleNamespaces
|
|
28286
|
+
for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
|
|
28287
|
+
var namespace = visibleNamespaces[nsi]
|
|
28288
|
+
if (namespace.prefix === '' && namespace.namespace === node.namespaceURI) {
|
|
28289
|
+
defaultNS = namespace.namespace
|
|
28290
|
+
break
|
|
28291
|
+
}
|
|
28292
|
+
}
|
|
28293
|
+
}
|
|
28294
|
+
if (defaultNS !== node.namespaceURI) {
|
|
28295
|
+
for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
|
|
28296
|
+
var namespace = visibleNamespaces[nsi]
|
|
28297
|
+
if (namespace.namespace === node.namespaceURI) {
|
|
28298
|
+
if (namespace.prefix) {
|
|
28299
|
+
prefixedNodeName = namespace.prefix + ':' + nodeName
|
|
28300
|
+
}
|
|
28301
|
+
break
|
|
28302
|
+
}
|
|
28303
|
+
}
|
|
28304
|
+
}
|
|
28305
|
+
}
|
|
28306
|
+
|
|
28307
|
+
buf.push('<', prefixedNodeName);
|
|
28308
|
+
|
|
28309
|
+
for(var i=0;i<len;i++){
|
|
28310
|
+
// add namespaces for attributes
|
|
28311
|
+
var attr = attrs.item(i);
|
|
28312
|
+
if (attr.prefix == 'xmlns') {
|
|
28313
|
+
visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
|
|
28314
|
+
}else if(attr.nodeName == 'xmlns'){
|
|
28315
|
+
visibleNamespaces.push({ prefix: '', namespace: attr.value });
|
|
28316
|
+
}
|
|
28317
|
+
}
|
|
28318
|
+
|
|
28319
|
+
for(var i=0;i<len;i++){
|
|
28320
|
+
var attr = attrs.item(i);
|
|
28321
|
+
if (needNamespaceDefine(attr,isHTML, visibleNamespaces)) {
|
|
28322
|
+
var prefix = attr.prefix||'';
|
|
28323
|
+
var uri = attr.namespaceURI;
|
|
28324
|
+
addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : "xmlns", uri);
|
|
28325
|
+
visibleNamespaces.push({ prefix: prefix, namespace:uri });
|
|
28326
|
+
}
|
|
28327
|
+
serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
|
|
28328
|
+
}
|
|
28329
|
+
|
|
28330
|
+
// add namespace for current node
|
|
28331
|
+
if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {
|
|
28332
|
+
var prefix = node.prefix||'';
|
|
28333
|
+
var uri = node.namespaceURI;
|
|
28334
|
+
addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : "xmlns", uri);
|
|
28335
|
+
visibleNamespaces.push({ prefix: prefix, namespace:uri });
|
|
28336
|
+
}
|
|
28337
|
+
|
|
28338
|
+
if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
|
|
28339
|
+
buf.push('>');
|
|
28340
|
+
//if is cdata child node
|
|
28341
|
+
if(isHTML && /^script$/i.test(nodeName)){
|
|
28342
|
+
while(child){
|
|
28343
|
+
if(child.data){
|
|
28344
|
+
buf.push(child.data);
|
|
28345
|
+
}else{
|
|
28346
|
+
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
|
|
28347
|
+
}
|
|
28348
|
+
child = child.nextSibling;
|
|
28349
|
+
}
|
|
28350
|
+
}else
|
|
28351
|
+
{
|
|
28352
|
+
while(child){
|
|
28353
|
+
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
|
|
28354
|
+
child = child.nextSibling;
|
|
28355
|
+
}
|
|
28356
|
+
}
|
|
28357
|
+
buf.push('</',prefixedNodeName,'>');
|
|
28358
|
+
}else{
|
|
28359
|
+
buf.push('/>');
|
|
28360
|
+
}
|
|
28361
|
+
// remove added visible namespaces
|
|
28362
|
+
//visibleNamespaces.length = startVisibleNamespaces;
|
|
28363
|
+
return;
|
|
28364
|
+
case DOCUMENT_NODE:
|
|
28365
|
+
case DOCUMENT_FRAGMENT_NODE:
|
|
28366
|
+
var child = node.firstChild;
|
|
28367
|
+
while(child){
|
|
28368
|
+
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
|
|
28369
|
+
child = child.nextSibling;
|
|
28370
|
+
}
|
|
28371
|
+
return;
|
|
28372
|
+
case ATTRIBUTE_NODE:
|
|
28373
|
+
return addSerializedAttribute(buf, node.name, node.value);
|
|
28374
|
+
case TEXT_NODE:
|
|
28375
|
+
/**
|
|
28376
|
+
* The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
|
|
28377
|
+
* except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section.
|
|
28378
|
+
* If they are needed elsewhere, they must be escaped using either numeric character references or the strings
|
|
28379
|
+
* `&` and `<` respectively.
|
|
28380
|
+
* The right angle bracket (>) may be represented using the string " > ", and must, for compatibility,
|
|
28381
|
+
* be escaped using either `>` or a character reference when it appears in the string `]]>` in content,
|
|
28382
|
+
* when that string is not marking the end of a CDATA section.
|
|
28383
|
+
*
|
|
28384
|
+
* In the content of elements, character data is any string of characters
|
|
28385
|
+
* which does not contain the start-delimiter of any markup
|
|
28386
|
+
* and does not include the CDATA-section-close delimiter, `]]>`.
|
|
28387
|
+
*
|
|
28388
|
+
* @see https://www.w3.org/TR/xml/#NT-CharData
|
|
28389
|
+
*/
|
|
28390
|
+
return buf.push(node.data
|
|
28391
|
+
.replace(/[<&]/g,_xmlEncoder)
|
|
28392
|
+
.replace(/]]>/g, ']]>')
|
|
28393
|
+
);
|
|
28394
|
+
case CDATA_SECTION_NODE:
|
|
28395
|
+
return buf.push( '<![CDATA[',node.data,']]>');
|
|
28396
|
+
case COMMENT_NODE:
|
|
28397
|
+
return buf.push( "<!--",node.data,"-->");
|
|
28398
|
+
case DOCUMENT_TYPE_NODE:
|
|
28399
|
+
var pubid = node.publicId;
|
|
28400
|
+
var sysid = node.systemId;
|
|
28401
|
+
buf.push('<!DOCTYPE ',node.name);
|
|
28402
|
+
if(pubid){
|
|
28403
|
+
buf.push(' PUBLIC ', pubid);
|
|
28404
|
+
if (sysid && sysid!='.') {
|
|
28405
|
+
buf.push(' ', sysid);
|
|
28406
|
+
}
|
|
28407
|
+
buf.push('>');
|
|
28408
|
+
}else if(sysid && sysid!='.'){
|
|
28409
|
+
buf.push(' SYSTEM ', sysid, '>');
|
|
28410
|
+
}else{
|
|
28411
|
+
var sub = node.internalSubset;
|
|
28412
|
+
if(sub){
|
|
28413
|
+
buf.push(" [",sub,"]");
|
|
28414
|
+
}
|
|
28415
|
+
buf.push(">");
|
|
28416
|
+
}
|
|
28417
|
+
return;
|
|
28418
|
+
case PROCESSING_INSTRUCTION_NODE:
|
|
28419
|
+
return buf.push( "<?",node.target," ",node.data,"?>");
|
|
28420
|
+
case ENTITY_REFERENCE_NODE:
|
|
28421
|
+
return buf.push( '&',node.nodeName,';');
|
|
28422
|
+
//case ENTITY_NODE:
|
|
28423
|
+
//case NOTATION_NODE:
|
|
28424
|
+
default:
|
|
28425
|
+
buf.push('??',node.nodeName);
|
|
28426
|
+
}
|
|
28427
|
+
}
|
|
28428
|
+
function importNode(doc,node,deep){
|
|
28429
|
+
var node2;
|
|
28430
|
+
switch (node.nodeType) {
|
|
28431
|
+
case ELEMENT_NODE:
|
|
28432
|
+
node2 = node.cloneNode(false);
|
|
28433
|
+
node2.ownerDocument = doc;
|
|
28434
|
+
//var attrs = node2.attributes;
|
|
28435
|
+
//var len = attrs.length;
|
|
28436
|
+
//for(var i=0;i<len;i++){
|
|
28437
|
+
//node2.setAttributeNodeNS(importNode(doc,attrs.item(i),deep));
|
|
28438
|
+
//}
|
|
28439
|
+
case DOCUMENT_FRAGMENT_NODE:
|
|
28440
|
+
break;
|
|
28441
|
+
case ATTRIBUTE_NODE:
|
|
28442
|
+
deep = true;
|
|
28443
|
+
break;
|
|
28444
|
+
//case ENTITY_REFERENCE_NODE:
|
|
28445
|
+
//case PROCESSING_INSTRUCTION_NODE:
|
|
28446
|
+
////case TEXT_NODE:
|
|
28447
|
+
//case CDATA_SECTION_NODE:
|
|
28448
|
+
//case COMMENT_NODE:
|
|
28449
|
+
// deep = false;
|
|
28450
|
+
// break;
|
|
28451
|
+
//case DOCUMENT_NODE:
|
|
28452
|
+
//case DOCUMENT_TYPE_NODE:
|
|
28453
|
+
//cannot be imported.
|
|
28454
|
+
//case ENTITY_NODE:
|
|
28455
|
+
//case NOTATION_NODE:
|
|
28456
|
+
//can not hit in level3
|
|
28457
|
+
//default:throw e;
|
|
28458
|
+
}
|
|
28459
|
+
if(!node2){
|
|
28460
|
+
node2 = node.cloneNode(false);//false
|
|
28461
|
+
}
|
|
28462
|
+
node2.ownerDocument = doc;
|
|
28463
|
+
node2.parentNode = null;
|
|
28464
|
+
if(deep){
|
|
28465
|
+
var child = node.firstChild;
|
|
28466
|
+
while(child){
|
|
28467
|
+
node2.appendChild(importNode(doc,child,deep));
|
|
28468
|
+
child = child.nextSibling;
|
|
28469
|
+
}
|
|
28470
|
+
}
|
|
28471
|
+
return node2;
|
|
28472
|
+
}
|
|
28473
|
+
//
|
|
28474
|
+
//var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1,
|
|
28475
|
+
// attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
|
|
28476
|
+
function cloneNode(doc,node,deep){
|
|
28477
|
+
var node2 = new node.constructor();
|
|
28478
|
+
for(var n in node){
|
|
28479
|
+
var v = node[n];
|
|
28480
|
+
if(typeof v != 'object' ){
|
|
28481
|
+
if(v != node2[n]){
|
|
28482
|
+
node2[n] = v;
|
|
28483
|
+
}
|
|
28484
|
+
}
|
|
28485
|
+
}
|
|
28486
|
+
if(node.childNodes){
|
|
28487
|
+
node2.childNodes = new NodeList();
|
|
28488
|
+
}
|
|
28489
|
+
node2.ownerDocument = doc;
|
|
28490
|
+
switch (node2.nodeType) {
|
|
28491
|
+
case ELEMENT_NODE:
|
|
28492
|
+
var attrs = node.attributes;
|
|
28493
|
+
var attrs2 = node2.attributes = new NamedNodeMap();
|
|
28494
|
+
var len = attrs.length
|
|
28495
|
+
attrs2._ownerElement = node2;
|
|
28496
|
+
for(var i=0;i<len;i++){
|
|
28497
|
+
node2.setAttributeNode(cloneNode(doc,attrs.item(i),true));
|
|
28498
|
+
}
|
|
28499
|
+
break;;
|
|
28500
|
+
case ATTRIBUTE_NODE:
|
|
28501
|
+
deep = true;
|
|
28502
|
+
}
|
|
28503
|
+
if(deep){
|
|
28504
|
+
var child = node.firstChild;
|
|
28505
|
+
while(child){
|
|
28506
|
+
node2.appendChild(cloneNode(doc,child,deep));
|
|
28507
|
+
child = child.nextSibling;
|
|
28508
|
+
}
|
|
28509
|
+
}
|
|
28510
|
+
return node2;
|
|
28511
|
+
}
|
|
28512
|
+
|
|
28513
|
+
function __set__(object,key,value){
|
|
28514
|
+
object[key] = value
|
|
28515
|
+
}
|
|
28516
|
+
//do dynamic
|
|
28517
|
+
try{
|
|
28518
|
+
if(Object.defineProperty){
|
|
28519
|
+
Object.defineProperty(LiveNodeList.prototype,'length',{
|
|
28520
|
+
get:function(){
|
|
28521
|
+
_updateLiveList(this);
|
|
28522
|
+
return this.$$length;
|
|
28523
|
+
}
|
|
28524
|
+
});
|
|
28525
|
+
|
|
28526
|
+
Object.defineProperty(Node.prototype,'textContent',{
|
|
28527
|
+
get:function(){
|
|
28528
|
+
return getTextContent(this);
|
|
28529
|
+
},
|
|
28530
|
+
|
|
28531
|
+
set:function(data){
|
|
28532
|
+
switch(this.nodeType){
|
|
28533
|
+
case ELEMENT_NODE:
|
|
28534
|
+
case DOCUMENT_FRAGMENT_NODE:
|
|
28535
|
+
while(this.firstChild){
|
|
28536
|
+
this.removeChild(this.firstChild);
|
|
28537
|
+
}
|
|
28538
|
+
if(data || String(data)){
|
|
28539
|
+
this.appendChild(this.ownerDocument.createTextNode(data));
|
|
28540
|
+
}
|
|
28541
|
+
break;
|
|
28542
|
+
|
|
28543
|
+
default:
|
|
28544
|
+
this.data = data;
|
|
28545
|
+
this.value = data;
|
|
28546
|
+
this.nodeValue = data;
|
|
28547
|
+
}
|
|
28548
|
+
}
|
|
28549
|
+
})
|
|
28550
|
+
|
|
28551
|
+
function getTextContent(node){
|
|
28552
|
+
switch(node.nodeType){
|
|
28553
|
+
case ELEMENT_NODE:
|
|
28554
|
+
case DOCUMENT_FRAGMENT_NODE:
|
|
28555
|
+
var buf = [];
|
|
28556
|
+
node = node.firstChild;
|
|
28557
|
+
while(node){
|
|
28558
|
+
if(node.nodeType!==7 && node.nodeType !==8){
|
|
28559
|
+
buf.push(getTextContent(node));
|
|
28560
|
+
}
|
|
28561
|
+
node = node.nextSibling;
|
|
28562
|
+
}
|
|
28563
|
+
return buf.join('');
|
|
28564
|
+
default:
|
|
28565
|
+
return node.nodeValue;
|
|
28566
|
+
}
|
|
28567
|
+
}
|
|
28568
|
+
|
|
28569
|
+
__set__ = function(object,key,value){
|
|
28570
|
+
//console.log(value)
|
|
28571
|
+
object['$$'+key] = value
|
|
28572
|
+
}
|
|
28573
|
+
}
|
|
28574
|
+
}catch(e){//ie8
|
|
28575
|
+
}
|
|
28576
|
+
|
|
28577
|
+
//if(typeof require == 'function'){
|
|
28578
|
+
exports.DocumentType = DocumentType;
|
|
28579
|
+
exports.DOMException = DOMException;
|
|
28580
|
+
exports.DOMImplementation = DOMImplementation;
|
|
28581
|
+
exports.Element = Element;
|
|
28582
|
+
exports.Node = Node;
|
|
28583
|
+
exports.NodeList = NodeList;
|
|
28584
|
+
exports.XMLSerializer = XMLSerializer;
|
|
28585
|
+
//}
|
|
28586
|
+
|
|
28587
|
+
|
|
28588
|
+
/***/ }),
|
|
28589
|
+
|
|
28590
|
+
/***/ "./node_modules/@xmldom/xmldom/lib/entities.js":
|
|
28591
|
+
/*!*****************************************************!*\
|
|
28592
|
+
!*** ./node_modules/@xmldom/xmldom/lib/entities.js ***!
|
|
28593
|
+
\*****************************************************/
|
|
28594
|
+
/*! no static exports found */
|
|
28595
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
28596
|
+
|
|
28597
|
+
var freeze = __webpack_require__(/*! ./conventions */ "./node_modules/@xmldom/xmldom/lib/conventions.js").freeze;
|
|
28598
|
+
|
|
28599
|
+
/**
|
|
28600
|
+
* The entities that are predefined in every XML document.
|
|
28601
|
+
*
|
|
28602
|
+
* @see https://www.w3.org/TR/2006/REC-xml11-20060816/#sec-predefined-ent W3C XML 1.1
|
|
28603
|
+
* @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-predefined-ent W3C XML 1.0
|
|
28604
|
+
* @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML Wikipedia
|
|
28605
|
+
*/
|
|
28606
|
+
exports.XML_ENTITIES = freeze({amp:'&', apos:"'", gt:'>', lt:'<', quot:'"'})
|
|
28607
|
+
|
|
28608
|
+
/**
|
|
28609
|
+
* A map of currently 241 entities that are detected in an HTML document.
|
|
28610
|
+
* They contain all entries from `XML_ENTITIES`.
|
|
28611
|
+
*
|
|
28612
|
+
* @see XML_ENTITIES
|
|
28613
|
+
* @see DOMParser.parseFromString
|
|
28614
|
+
* @see DOMImplementation.prototype.createHTMLDocument
|
|
28615
|
+
* @see https://html.spec.whatwg.org/#named-character-references WHATWG HTML(5) Spec
|
|
28616
|
+
* @see https://www.w3.org/TR/xml-entity-names/ W3C XML Entity Names
|
|
28617
|
+
* @see https://www.w3.org/TR/html4/sgml/entities.html W3C HTML4/SGML
|
|
28618
|
+
* @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML Wikipedia (HTML)
|
|
28619
|
+
* @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML Wikpedia (XHTML)
|
|
28620
|
+
*/
|
|
28621
|
+
exports.HTML_ENTITIES = freeze({
|
|
28622
|
+
lt: '<',
|
|
28623
|
+
gt: '>',
|
|
28624
|
+
amp: '&',
|
|
28625
|
+
quot: '"',
|
|
28626
|
+
apos: "'",
|
|
28627
|
+
Agrave: "À",
|
|
28628
|
+
Aacute: "Á",
|
|
28629
|
+
Acirc: "Â",
|
|
28630
|
+
Atilde: "Ã",
|
|
28631
|
+
Auml: "Ä",
|
|
28632
|
+
Aring: "Å",
|
|
28633
|
+
AElig: "Æ",
|
|
28634
|
+
Ccedil: "Ç",
|
|
28635
|
+
Egrave: "È",
|
|
28636
|
+
Eacute: "É",
|
|
28637
|
+
Ecirc: "Ê",
|
|
28638
|
+
Euml: "Ë",
|
|
28639
|
+
Igrave: "Ì",
|
|
28640
|
+
Iacute: "Í",
|
|
28641
|
+
Icirc: "Î",
|
|
28642
|
+
Iuml: "Ï",
|
|
28643
|
+
ETH: "Ð",
|
|
28644
|
+
Ntilde: "Ñ",
|
|
28645
|
+
Ograve: "Ò",
|
|
28646
|
+
Oacute: "Ó",
|
|
28647
|
+
Ocirc: "Ô",
|
|
28648
|
+
Otilde: "Õ",
|
|
28649
|
+
Ouml: "Ö",
|
|
28650
|
+
Oslash: "Ø",
|
|
28651
|
+
Ugrave: "Ù",
|
|
28652
|
+
Uacute: "Ú",
|
|
28653
|
+
Ucirc: "Û",
|
|
28654
|
+
Uuml: "Ü",
|
|
28655
|
+
Yacute: "Ý",
|
|
28656
|
+
THORN: "Þ",
|
|
28657
|
+
szlig: "ß",
|
|
28658
|
+
agrave: "à",
|
|
28659
|
+
aacute: "á",
|
|
28660
|
+
acirc: "â",
|
|
28661
|
+
atilde: "ã",
|
|
28662
|
+
auml: "ä",
|
|
28663
|
+
aring: "å",
|
|
28664
|
+
aelig: "æ",
|
|
28665
|
+
ccedil: "ç",
|
|
28666
|
+
egrave: "è",
|
|
28667
|
+
eacute: "é",
|
|
28668
|
+
ecirc: "ê",
|
|
28669
|
+
euml: "ë",
|
|
28670
|
+
igrave: "ì",
|
|
28671
|
+
iacute: "í",
|
|
28672
|
+
icirc: "î",
|
|
28673
|
+
iuml: "ï",
|
|
28674
|
+
eth: "ð",
|
|
28675
|
+
ntilde: "ñ",
|
|
28676
|
+
ograve: "ò",
|
|
28677
|
+
oacute: "ó",
|
|
28678
|
+
ocirc: "ô",
|
|
28679
|
+
otilde: "õ",
|
|
28680
|
+
ouml: "ö",
|
|
28681
|
+
oslash: "ø",
|
|
28682
|
+
ugrave: "ù",
|
|
28683
|
+
uacute: "ú",
|
|
28684
|
+
ucirc: "û",
|
|
28685
|
+
uuml: "ü",
|
|
28686
|
+
yacute: "ý",
|
|
28687
|
+
thorn: "þ",
|
|
28688
|
+
yuml: "ÿ",
|
|
28689
|
+
nbsp: "\u00a0",
|
|
28690
|
+
iexcl: "¡",
|
|
28691
|
+
cent: "¢",
|
|
28692
|
+
pound: "£",
|
|
28693
|
+
curren: "¤",
|
|
28694
|
+
yen: "¥",
|
|
28695
|
+
brvbar: "¦",
|
|
28696
|
+
sect: "§",
|
|
28697
|
+
uml: "¨",
|
|
28698
|
+
copy: "©",
|
|
28699
|
+
ordf: "ª",
|
|
28700
|
+
laquo: "«",
|
|
28701
|
+
not: "¬",
|
|
28702
|
+
shy: "",
|
|
28703
|
+
reg: "®",
|
|
28704
|
+
macr: "¯",
|
|
28705
|
+
deg: "°",
|
|
28706
|
+
plusmn: "±",
|
|
28707
|
+
sup2: "²",
|
|
28708
|
+
sup3: "³",
|
|
28709
|
+
acute: "´",
|
|
28710
|
+
micro: "µ",
|
|
28711
|
+
para: "¶",
|
|
28712
|
+
middot: "·",
|
|
28713
|
+
cedil: "¸",
|
|
28714
|
+
sup1: "¹",
|
|
28715
|
+
ordm: "º",
|
|
28716
|
+
raquo: "»",
|
|
28717
|
+
frac14: "¼",
|
|
28718
|
+
frac12: "½",
|
|
28719
|
+
frac34: "¾",
|
|
28720
|
+
iquest: "¿",
|
|
28721
|
+
times: "×",
|
|
28722
|
+
divide: "÷",
|
|
28723
|
+
forall: "∀",
|
|
28724
|
+
part: "∂",
|
|
28725
|
+
exist: "∃",
|
|
28726
|
+
empty: "∅",
|
|
28727
|
+
nabla: "∇",
|
|
28728
|
+
isin: "∈",
|
|
28729
|
+
notin: "∉",
|
|
28730
|
+
ni: "∋",
|
|
28731
|
+
prod: "∏",
|
|
28732
|
+
sum: "∑",
|
|
28733
|
+
minus: "−",
|
|
28734
|
+
lowast: "∗",
|
|
28735
|
+
radic: "√",
|
|
28736
|
+
prop: "∝",
|
|
28737
|
+
infin: "∞",
|
|
28738
|
+
ang: "∠",
|
|
28739
|
+
and: "∧",
|
|
28740
|
+
or: "∨",
|
|
28741
|
+
cap: "∩",
|
|
28742
|
+
cup: "∪",
|
|
28743
|
+
'int': "∫",
|
|
28744
|
+
there4: "∴",
|
|
28745
|
+
sim: "∼",
|
|
28746
|
+
cong: "≅",
|
|
28747
|
+
asymp: "≈",
|
|
28748
|
+
ne: "≠",
|
|
28749
|
+
equiv: "≡",
|
|
28750
|
+
le: "≤",
|
|
28751
|
+
ge: "≥",
|
|
28752
|
+
sub: "⊂",
|
|
28753
|
+
sup: "⊃",
|
|
28754
|
+
nsub: "⊄",
|
|
28755
|
+
sube: "⊆",
|
|
28756
|
+
supe: "⊇",
|
|
28757
|
+
oplus: "⊕",
|
|
28758
|
+
otimes: "⊗",
|
|
28759
|
+
perp: "⊥",
|
|
28760
|
+
sdot: "⋅",
|
|
28761
|
+
Alpha: "Α",
|
|
28762
|
+
Beta: "Β",
|
|
28763
|
+
Gamma: "Γ",
|
|
28764
|
+
Delta: "Δ",
|
|
28765
|
+
Epsilon: "Ε",
|
|
28766
|
+
Zeta: "Ζ",
|
|
28767
|
+
Eta: "Η",
|
|
28768
|
+
Theta: "Θ",
|
|
28769
|
+
Iota: "Ι",
|
|
28770
|
+
Kappa: "Κ",
|
|
28771
|
+
Lambda: "Λ",
|
|
28772
|
+
Mu: "Μ",
|
|
28773
|
+
Nu: "Ν",
|
|
28774
|
+
Xi: "Ξ",
|
|
28775
|
+
Omicron: "Ο",
|
|
28776
|
+
Pi: "Π",
|
|
28777
|
+
Rho: "Ρ",
|
|
28778
|
+
Sigma: "Σ",
|
|
28779
|
+
Tau: "Τ",
|
|
28780
|
+
Upsilon: "Υ",
|
|
28781
|
+
Phi: "Φ",
|
|
28782
|
+
Chi: "Χ",
|
|
28783
|
+
Psi: "Ψ",
|
|
28784
|
+
Omega: "Ω",
|
|
28785
|
+
alpha: "α",
|
|
28786
|
+
beta: "β",
|
|
28787
|
+
gamma: "γ",
|
|
28788
|
+
delta: "δ",
|
|
28789
|
+
epsilon: "ε",
|
|
28790
|
+
zeta: "ζ",
|
|
28791
|
+
eta: "η",
|
|
28792
|
+
theta: "θ",
|
|
28793
|
+
iota: "ι",
|
|
28794
|
+
kappa: "κ",
|
|
28795
|
+
lambda: "λ",
|
|
28796
|
+
mu: "μ",
|
|
28797
|
+
nu: "ν",
|
|
28798
|
+
xi: "ξ",
|
|
28799
|
+
omicron: "ο",
|
|
28800
|
+
pi: "π",
|
|
28801
|
+
rho: "ρ",
|
|
28802
|
+
sigmaf: "ς",
|
|
28803
|
+
sigma: "σ",
|
|
28804
|
+
tau: "τ",
|
|
28805
|
+
upsilon: "υ",
|
|
28806
|
+
phi: "φ",
|
|
28807
|
+
chi: "χ",
|
|
28808
|
+
psi: "ψ",
|
|
28809
|
+
omega: "ω",
|
|
28810
|
+
thetasym: "ϑ",
|
|
28811
|
+
upsih: "ϒ",
|
|
28812
|
+
piv: "ϖ",
|
|
28813
|
+
OElig: "Œ",
|
|
28814
|
+
oelig: "œ",
|
|
28815
|
+
Scaron: "Š",
|
|
28816
|
+
scaron: "š",
|
|
28817
|
+
Yuml: "Ÿ",
|
|
28818
|
+
fnof: "ƒ",
|
|
28819
|
+
circ: "ˆ",
|
|
28820
|
+
tilde: "˜",
|
|
28821
|
+
ensp: " ",
|
|
28822
|
+
emsp: " ",
|
|
28823
|
+
thinsp: " ",
|
|
28824
|
+
zwnj: "",
|
|
28825
|
+
zwj: "",
|
|
28826
|
+
lrm: "",
|
|
28827
|
+
rlm: "",
|
|
28828
|
+
ndash: "–",
|
|
28829
|
+
mdash: "—",
|
|
28830
|
+
lsquo: "‘",
|
|
28831
|
+
rsquo: "’",
|
|
28832
|
+
sbquo: "‚",
|
|
28833
|
+
ldquo: "“",
|
|
28834
|
+
rdquo: "”",
|
|
28835
|
+
bdquo: "„",
|
|
28836
|
+
dagger: "†",
|
|
28837
|
+
Dagger: "‡",
|
|
28838
|
+
bull: "•",
|
|
28839
|
+
hellip: "…",
|
|
28840
|
+
permil: "‰",
|
|
28841
|
+
prime: "′",
|
|
28842
|
+
Prime: "″",
|
|
28843
|
+
lsaquo: "‹",
|
|
28844
|
+
rsaquo: "›",
|
|
28845
|
+
oline: "‾",
|
|
28846
|
+
euro: "€",
|
|
28847
|
+
trade: "™",
|
|
28848
|
+
larr: "←",
|
|
28849
|
+
uarr: "↑",
|
|
28850
|
+
rarr: "→",
|
|
28851
|
+
darr: "↓",
|
|
28852
|
+
harr: "↔",
|
|
28853
|
+
crarr: "↵",
|
|
28854
|
+
lceil: "⌈",
|
|
28855
|
+
rceil: "⌉",
|
|
28856
|
+
lfloor: "⌊",
|
|
28857
|
+
rfloor: "⌋",
|
|
28858
|
+
loz: "◊",
|
|
28859
|
+
spades: "♠",
|
|
28860
|
+
clubs: "♣",
|
|
28861
|
+
hearts: "♥",
|
|
28862
|
+
diams: "♦"
|
|
28863
|
+
});
|
|
28864
|
+
|
|
28865
|
+
/**
|
|
28866
|
+
* @deprecated use `HTML_ENTITIES` instead
|
|
28867
|
+
* @see HTML_ENTITIES
|
|
28868
|
+
*/
|
|
28869
|
+
exports.entityMap = exports.HTML_ENTITIES
|
|
28870
|
+
|
|
28871
|
+
|
|
28872
|
+
/***/ }),
|
|
28873
|
+
|
|
28874
|
+
/***/ "./node_modules/@xmldom/xmldom/lib/index.js":
|
|
28875
|
+
/*!**************************************************!*\
|
|
28876
|
+
!*** ./node_modules/@xmldom/xmldom/lib/index.js ***!
|
|
28877
|
+
\**************************************************/
|
|
28878
|
+
/*! no static exports found */
|
|
28879
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
28880
|
+
|
|
28881
|
+
var dom = __webpack_require__(/*! ./dom */ "./node_modules/@xmldom/xmldom/lib/dom.js")
|
|
28882
|
+
exports.DOMImplementation = dom.DOMImplementation
|
|
28883
|
+
exports.XMLSerializer = dom.XMLSerializer
|
|
28884
|
+
exports.DOMParser = __webpack_require__(/*! ./dom-parser */ "./node_modules/@xmldom/xmldom/lib/dom-parser.js").DOMParser
|
|
28885
|
+
|
|
28886
|
+
|
|
28887
|
+
/***/ }),
|
|
28888
|
+
|
|
28889
|
+
/***/ "./node_modules/@xmldom/xmldom/lib/sax.js":
|
|
28890
|
+
/*!************************************************!*\
|
|
28891
|
+
!*** ./node_modules/@xmldom/xmldom/lib/sax.js ***!
|
|
28892
|
+
\************************************************/
|
|
28893
|
+
/*! no static exports found */
|
|
28894
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
28895
|
+
|
|
28896
|
+
var NAMESPACE = __webpack_require__(/*! ./conventions */ "./node_modules/@xmldom/xmldom/lib/conventions.js").NAMESPACE;
|
|
28897
|
+
|
|
28898
|
+
//[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
|
28899
|
+
//[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
|
|
28900
|
+
//[5] Name ::= NameStartChar (NameChar)*
|
|
28901
|
+
var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]///\u10000-\uEFFFF
|
|
28902
|
+
var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
|
|
28903
|
+
var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');
|
|
28904
|
+
//var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/
|
|
28905
|
+
//var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')
|
|
28906
|
+
|
|
28907
|
+
//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
|
|
28908
|
+
//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
|
|
28909
|
+
var S_TAG = 0;//tag name offerring
|
|
28910
|
+
var S_ATTR = 1;//attr name offerring
|
|
28911
|
+
var S_ATTR_SPACE=2;//attr name end and space offer
|
|
28912
|
+
var S_EQ = 3;//=space?
|
|
28913
|
+
var S_ATTR_NOQUOT_VALUE = 4;//attr value(no quot value only)
|
|
28914
|
+
var S_ATTR_END = 5;//attr value end and no space(quot end)
|
|
28915
|
+
var S_TAG_SPACE = 6;//(attr value end || tag end ) && (space offer)
|
|
28916
|
+
var S_TAG_CLOSE = 7;//closed el<el />
|
|
28917
|
+
|
|
28918
|
+
/**
|
|
28919
|
+
* Creates an error that will not be caught by XMLReader aka the SAX parser.
|
|
28920
|
+
*
|
|
28921
|
+
* @param {string} message
|
|
28922
|
+
* @param {any?} locator Optional, can provide details about the location in the source
|
|
28923
|
+
* @constructor
|
|
28924
|
+
*/
|
|
28925
|
+
function ParseError(message, locator) {
|
|
28926
|
+
this.message = message
|
|
28927
|
+
this.locator = locator
|
|
28928
|
+
if(Error.captureStackTrace) Error.captureStackTrace(this, ParseError);
|
|
28929
|
+
}
|
|
28930
|
+
ParseError.prototype = new Error();
|
|
28931
|
+
ParseError.prototype.name = ParseError.name
|
|
28932
|
+
|
|
28933
|
+
function XMLReader(){
|
|
28934
|
+
|
|
28935
|
+
}
|
|
28936
|
+
|
|
28937
|
+
XMLReader.prototype = {
|
|
28938
|
+
parse:function(source,defaultNSMap,entityMap){
|
|
28939
|
+
var domBuilder = this.domBuilder;
|
|
28940
|
+
domBuilder.startDocument();
|
|
28941
|
+
_copy(defaultNSMap ,defaultNSMap = {})
|
|
28942
|
+
parse(source,defaultNSMap,entityMap,
|
|
28943
|
+
domBuilder,this.errorHandler);
|
|
28944
|
+
domBuilder.endDocument();
|
|
28945
|
+
}
|
|
28946
|
+
}
|
|
28947
|
+
function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
|
|
28948
|
+
function fixedFromCharCode(code) {
|
|
28949
|
+
// String.prototype.fromCharCode does not supports
|
|
28950
|
+
// > 2 bytes unicode chars directly
|
|
28951
|
+
if (code > 0xffff) {
|
|
28952
|
+
code -= 0x10000;
|
|
28953
|
+
var surrogate1 = 0xd800 + (code >> 10)
|
|
28954
|
+
, surrogate2 = 0xdc00 + (code & 0x3ff);
|
|
28955
|
+
|
|
28956
|
+
return String.fromCharCode(surrogate1, surrogate2);
|
|
28957
|
+
} else {
|
|
28958
|
+
return String.fromCharCode(code);
|
|
28959
|
+
}
|
|
28960
|
+
}
|
|
28961
|
+
function entityReplacer(a){
|
|
28962
|
+
var k = a.slice(1,-1);
|
|
28963
|
+
if(k in entityMap){
|
|
28964
|
+
return entityMap[k];
|
|
28965
|
+
}else if(k.charAt(0) === '#'){
|
|
28966
|
+
return fixedFromCharCode(parseInt(k.substr(1).replace('x','0x')))
|
|
28967
|
+
}else{
|
|
28968
|
+
errorHandler.error('entity not found:'+a);
|
|
28969
|
+
return a;
|
|
28970
|
+
}
|
|
28971
|
+
}
|
|
28972
|
+
function appendText(end){//has some bugs
|
|
28973
|
+
if(end>start){
|
|
28974
|
+
var xt = source.substring(start,end).replace(/&#?\w+;/g,entityReplacer);
|
|
28975
|
+
locator&&position(start);
|
|
28976
|
+
domBuilder.characters(xt,0,end-start);
|
|
28977
|
+
start = end
|
|
28978
|
+
}
|
|
28979
|
+
}
|
|
28980
|
+
function position(p,m){
|
|
28981
|
+
while(p>=lineEnd && (m = linePattern.exec(source))){
|
|
28982
|
+
lineStart = m.index;
|
|
28983
|
+
lineEnd = lineStart + m[0].length;
|
|
28984
|
+
locator.lineNumber++;
|
|
28985
|
+
//console.log('line++:',locator,startPos,endPos)
|
|
28986
|
+
}
|
|
28987
|
+
locator.columnNumber = p-lineStart+1;
|
|
28988
|
+
}
|
|
28989
|
+
var lineStart = 0;
|
|
28990
|
+
var lineEnd = 0;
|
|
28991
|
+
var linePattern = /.*(?:\r\n?|\n)|.*$/g
|
|
28992
|
+
var locator = domBuilder.locator;
|
|
28993
|
+
|
|
28994
|
+
var parseStack = [{currentNSMap:defaultNSMapCopy}]
|
|
28995
|
+
var closeMap = {};
|
|
28996
|
+
var start = 0;
|
|
28997
|
+
while(true){
|
|
28998
|
+
try{
|
|
28999
|
+
var tagStart = source.indexOf('<',start);
|
|
29000
|
+
if(tagStart<0){
|
|
29001
|
+
if(!source.substr(start).match(/^\s*$/)){
|
|
29002
|
+
var doc = domBuilder.doc;
|
|
29003
|
+
var text = doc.createTextNode(source.substr(start));
|
|
29004
|
+
doc.appendChild(text);
|
|
29005
|
+
domBuilder.currentElement = text;
|
|
29006
|
+
}
|
|
29007
|
+
return;
|
|
29008
|
+
}
|
|
29009
|
+
if(tagStart>start){
|
|
29010
|
+
appendText(tagStart);
|
|
29011
|
+
}
|
|
29012
|
+
switch(source.charAt(tagStart+1)){
|
|
29013
|
+
case '/':
|
|
29014
|
+
var end = source.indexOf('>',tagStart+3);
|
|
29015
|
+
var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, '');
|
|
29016
|
+
var config = parseStack.pop();
|
|
29017
|
+
if(end<0){
|
|
29018
|
+
|
|
29019
|
+
tagName = source.substring(tagStart+2).replace(/[\s<].*/,'');
|
|
29020
|
+
errorHandler.error("end tag name: "+tagName+' is not complete:'+config.tagName);
|
|
29021
|
+
end = tagStart+1+tagName.length;
|
|
29022
|
+
}else if(tagName.match(/\s</)){
|
|
29023
|
+
tagName = tagName.replace(/[\s<].*/,'');
|
|
29024
|
+
errorHandler.error("end tag name: "+tagName+' maybe not complete');
|
|
29025
|
+
end = tagStart+1+tagName.length;
|
|
29026
|
+
}
|
|
29027
|
+
var localNSMap = config.localNSMap;
|
|
29028
|
+
var endMatch = config.tagName == tagName;
|
|
29029
|
+
var endIgnoreCaseMach = endMatch || config.tagName&&config.tagName.toLowerCase() == tagName.toLowerCase()
|
|
29030
|
+
if(endIgnoreCaseMach){
|
|
29031
|
+
domBuilder.endElement(config.uri,config.localName,tagName);
|
|
29032
|
+
if(localNSMap){
|
|
29033
|
+
for(var prefix in localNSMap){
|
|
29034
|
+
domBuilder.endPrefixMapping(prefix) ;
|
|
29035
|
+
}
|
|
29036
|
+
}
|
|
29037
|
+
if(!endMatch){
|
|
29038
|
+
errorHandler.fatalError("end tag name: "+tagName+' is not match the current start tagName:'+config.tagName ); // No known test case
|
|
29039
|
+
}
|
|
29040
|
+
}else{
|
|
29041
|
+
parseStack.push(config)
|
|
29042
|
+
}
|
|
29043
|
+
|
|
29044
|
+
end++;
|
|
29045
|
+
break;
|
|
29046
|
+
// end elment
|
|
29047
|
+
case '?':// <?...?>
|
|
29048
|
+
locator&&position(tagStart);
|
|
29049
|
+
end = parseInstruction(source,tagStart,domBuilder);
|
|
29050
|
+
break;
|
|
29051
|
+
case '!':// <!doctype,<![CDATA,<!--
|
|
29052
|
+
locator&&position(tagStart);
|
|
29053
|
+
end = parseDCC(source,tagStart,domBuilder,errorHandler);
|
|
29054
|
+
break;
|
|
29055
|
+
default:
|
|
29056
|
+
locator&&position(tagStart);
|
|
29057
|
+
var el = new ElementAttributes();
|
|
29058
|
+
var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
|
|
29059
|
+
//elStartEnd
|
|
29060
|
+
var end = parseElementStartPart(source,tagStart,el,currentNSMap,entityReplacer,errorHandler);
|
|
29061
|
+
var len = el.length;
|
|
29062
|
+
|
|
29063
|
+
|
|
29064
|
+
if(!el.closed && fixSelfClosed(source,end,el.tagName,closeMap)){
|
|
29065
|
+
el.closed = true;
|
|
29066
|
+
if(!entityMap.nbsp){
|
|
29067
|
+
errorHandler.warning('unclosed xml attribute');
|
|
29068
|
+
}
|
|
29069
|
+
}
|
|
29070
|
+
if(locator && len){
|
|
29071
|
+
var locator2 = copyLocator(locator,{});
|
|
29072
|
+
//try{//attribute position fixed
|
|
29073
|
+
for(var i = 0;i<len;i++){
|
|
29074
|
+
var a = el[i];
|
|
29075
|
+
position(a.offset);
|
|
29076
|
+
a.locator = copyLocator(locator,{});
|
|
29077
|
+
}
|
|
29078
|
+
domBuilder.locator = locator2
|
|
29079
|
+
if(appendElement(el,domBuilder,currentNSMap)){
|
|
29080
|
+
parseStack.push(el)
|
|
29081
|
+
}
|
|
29082
|
+
domBuilder.locator = locator;
|
|
29083
|
+
}else{
|
|
29084
|
+
if(appendElement(el,domBuilder,currentNSMap)){
|
|
29085
|
+
parseStack.push(el)
|
|
29086
|
+
}
|
|
29087
|
+
}
|
|
29088
|
+
|
|
29089
|
+
if (NAMESPACE.isHTML(el.uri) && !el.closed) {
|
|
29090
|
+
end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder)
|
|
29091
|
+
} else {
|
|
29092
|
+
end++;
|
|
29093
|
+
}
|
|
29094
|
+
}
|
|
29095
|
+
}catch(e){
|
|
29096
|
+
if (e instanceof ParseError) {
|
|
29097
|
+
throw e;
|
|
29098
|
+
}
|
|
29099
|
+
errorHandler.error('element parse error: '+e)
|
|
29100
|
+
end = -1;
|
|
29101
|
+
}
|
|
29102
|
+
if(end>start){
|
|
29103
|
+
start = end;
|
|
29104
|
+
}else{
|
|
29105
|
+
//TODO: 这里有可能sax回退,有位置错误风险
|
|
29106
|
+
appendText(Math.max(tagStart,start)+1);
|
|
29107
|
+
}
|
|
29108
|
+
}
|
|
29109
|
+
}
|
|
29110
|
+
function copyLocator(f,t){
|
|
29111
|
+
t.lineNumber = f.lineNumber;
|
|
29112
|
+
t.columnNumber = f.columnNumber;
|
|
29113
|
+
return t;
|
|
29114
|
+
}
|
|
29115
|
+
|
|
29116
|
+
/**
|
|
29117
|
+
* @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack);
|
|
29118
|
+
* @return end of the elementStartPart(end of elementEndPart for selfClosed el)
|
|
29119
|
+
*/
|
|
29120
|
+
function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,errorHandler){
|
|
29121
|
+
|
|
29122
|
+
/**
|
|
29123
|
+
* @param {string} qname
|
|
29124
|
+
* @param {string} value
|
|
29125
|
+
* @param {number} startIndex
|
|
29126
|
+
*/
|
|
29127
|
+
function addAttribute(qname, value, startIndex) {
|
|
29128
|
+
if (el.attributeNames.hasOwnProperty(qname)) {
|
|
29129
|
+
errorHandler.fatalError('Attribute ' + qname + ' redefined')
|
|
29130
|
+
}
|
|
29131
|
+
el.addValue(
|
|
29132
|
+
qname,
|
|
29133
|
+
// @see https://www.w3.org/TR/xml/#AVNormalize
|
|
29134
|
+
// since the xmldom sax parser does not "interpret" DTD the following is not implemented:
|
|
29135
|
+
// - recursive replacement of (DTD) entity references
|
|
29136
|
+
// - trimming and collapsing multiple spaces into a single one for attributes that are not of type CDATA
|
|
29137
|
+
value.replace(/[\t\n\r]/g, ' ').replace(/&#?\w+;/g, entityReplacer),
|
|
29138
|
+
startIndex
|
|
29139
|
+
)
|
|
29140
|
+
}
|
|
29141
|
+
var attrName;
|
|
29142
|
+
var value;
|
|
29143
|
+
var p = ++start;
|
|
29144
|
+
var s = S_TAG;//status
|
|
29145
|
+
while(true){
|
|
29146
|
+
var c = source.charAt(p);
|
|
29147
|
+
switch(c){
|
|
29148
|
+
case '=':
|
|
29149
|
+
if(s === S_ATTR){//attrName
|
|
29150
|
+
attrName = source.slice(start,p);
|
|
29151
|
+
s = S_EQ;
|
|
29152
|
+
}else if(s === S_ATTR_SPACE){
|
|
29153
|
+
s = S_EQ;
|
|
29154
|
+
}else{
|
|
29155
|
+
//fatalError: equal must after attrName or space after attrName
|
|
29156
|
+
throw new Error('attribute equal must after attrName'); // No known test case
|
|
29157
|
+
}
|
|
29158
|
+
break;
|
|
29159
|
+
case '\'':
|
|
29160
|
+
case '"':
|
|
29161
|
+
if(s === S_EQ || s === S_ATTR //|| s == S_ATTR_SPACE
|
|
29162
|
+
){//equal
|
|
29163
|
+
if(s === S_ATTR){
|
|
29164
|
+
errorHandler.warning('attribute value must after "="')
|
|
29165
|
+
attrName = source.slice(start,p)
|
|
29166
|
+
}
|
|
29167
|
+
start = p+1;
|
|
29168
|
+
p = source.indexOf(c,start)
|
|
29169
|
+
if(p>0){
|
|
29170
|
+
value = source.slice(start, p);
|
|
29171
|
+
addAttribute(attrName, value, start-1);
|
|
29172
|
+
s = S_ATTR_END;
|
|
29173
|
+
}else{
|
|
29174
|
+
//fatalError: no end quot match
|
|
29175
|
+
throw new Error('attribute value no end \''+c+'\' match');
|
|
29176
|
+
}
|
|
29177
|
+
}else if(s == S_ATTR_NOQUOT_VALUE){
|
|
29178
|
+
value = source.slice(start, p);
|
|
29179
|
+
addAttribute(attrName, value, start);
|
|
29180
|
+
errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+')!!');
|
|
29181
|
+
start = p+1;
|
|
29182
|
+
s = S_ATTR_END
|
|
29183
|
+
}else{
|
|
29184
|
+
//fatalError: no equal before
|
|
29185
|
+
throw new Error('attribute value must after "="'); // No known test case
|
|
29186
|
+
}
|
|
29187
|
+
break;
|
|
29188
|
+
case '/':
|
|
29189
|
+
switch(s){
|
|
29190
|
+
case S_TAG:
|
|
29191
|
+
el.setTagName(source.slice(start,p));
|
|
29192
|
+
case S_ATTR_END:
|
|
29193
|
+
case S_TAG_SPACE:
|
|
29194
|
+
case S_TAG_CLOSE:
|
|
29195
|
+
s =S_TAG_CLOSE;
|
|
29196
|
+
el.closed = true;
|
|
29197
|
+
case S_ATTR_NOQUOT_VALUE:
|
|
29198
|
+
case S_ATTR:
|
|
29199
|
+
case S_ATTR_SPACE:
|
|
29200
|
+
break;
|
|
29201
|
+
//case S_EQ:
|
|
29202
|
+
default:
|
|
29203
|
+
throw new Error("attribute invalid close char('/')") // No known test case
|
|
29204
|
+
}
|
|
29205
|
+
break;
|
|
29206
|
+
case ''://end document
|
|
29207
|
+
errorHandler.error('unexpected end of input');
|
|
29208
|
+
if(s == S_TAG){
|
|
29209
|
+
el.setTagName(source.slice(start,p));
|
|
29210
|
+
}
|
|
29211
|
+
return p;
|
|
29212
|
+
case '>':
|
|
29213
|
+
switch(s){
|
|
29214
|
+
case S_TAG:
|
|
29215
|
+
el.setTagName(source.slice(start,p));
|
|
29216
|
+
case S_ATTR_END:
|
|
29217
|
+
case S_TAG_SPACE:
|
|
29218
|
+
case S_TAG_CLOSE:
|
|
29219
|
+
break;//normal
|
|
29220
|
+
case S_ATTR_NOQUOT_VALUE://Compatible state
|
|
29221
|
+
case S_ATTR:
|
|
29222
|
+
value = source.slice(start,p);
|
|
29223
|
+
if(value.slice(-1) === '/'){
|
|
29224
|
+
el.closed = true;
|
|
29225
|
+
value = value.slice(0,-1)
|
|
29226
|
+
}
|
|
29227
|
+
case S_ATTR_SPACE:
|
|
29228
|
+
if(s === S_ATTR_SPACE){
|
|
29229
|
+
value = attrName;
|
|
29230
|
+
}
|
|
29231
|
+
if(s == S_ATTR_NOQUOT_VALUE){
|
|
29232
|
+
errorHandler.warning('attribute "'+value+'" missed quot(")!');
|
|
29233
|
+
addAttribute(attrName, value, start)
|
|
29234
|
+
}else{
|
|
29235
|
+
if(!NAMESPACE.isHTML(currentNSMap['']) || !value.match(/^(?:disabled|checked|selected)$/i)){
|
|
29236
|
+
errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!')
|
|
29237
|
+
}
|
|
29238
|
+
addAttribute(value, value, start)
|
|
29239
|
+
}
|
|
29240
|
+
break;
|
|
29241
|
+
case S_EQ:
|
|
29242
|
+
throw new Error('attribute value missed!!');
|
|
29243
|
+
}
|
|
29244
|
+
// console.log(tagName,tagNamePattern,tagNamePattern.test(tagName))
|
|
29245
|
+
return p;
|
|
29246
|
+
/*xml space '\x20' | #x9 | #xD | #xA; */
|
|
29247
|
+
case '\u0080':
|
|
29248
|
+
c = ' ';
|
|
29249
|
+
default:
|
|
29250
|
+
if(c<= ' '){//space
|
|
29251
|
+
switch(s){
|
|
29252
|
+
case S_TAG:
|
|
29253
|
+
el.setTagName(source.slice(start,p));//tagName
|
|
29254
|
+
s = S_TAG_SPACE;
|
|
29255
|
+
break;
|
|
29256
|
+
case S_ATTR:
|
|
29257
|
+
attrName = source.slice(start,p)
|
|
29258
|
+
s = S_ATTR_SPACE;
|
|
29259
|
+
break;
|
|
29260
|
+
case S_ATTR_NOQUOT_VALUE:
|
|
29261
|
+
var value = source.slice(start, p);
|
|
29262
|
+
errorHandler.warning('attribute "'+value+'" missed quot(")!!');
|
|
29263
|
+
addAttribute(attrName, value, start)
|
|
29264
|
+
case S_ATTR_END:
|
|
29265
|
+
s = S_TAG_SPACE;
|
|
29266
|
+
break;
|
|
29267
|
+
//case S_TAG_SPACE:
|
|
29268
|
+
//case S_EQ:
|
|
29269
|
+
//case S_ATTR_SPACE:
|
|
29270
|
+
// void();break;
|
|
29271
|
+
//case S_TAG_CLOSE:
|
|
29272
|
+
//ignore warning
|
|
29273
|
+
}
|
|
29274
|
+
}else{//not space
|
|
29275
|
+
//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
|
|
29276
|
+
//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
|
|
29277
|
+
switch(s){
|
|
29278
|
+
//case S_TAG:void();break;
|
|
29279
|
+
//case S_ATTR:void();break;
|
|
29280
|
+
//case S_ATTR_NOQUOT_VALUE:void();break;
|
|
29281
|
+
case S_ATTR_SPACE:
|
|
29282
|
+
var tagName = el.tagName;
|
|
29283
|
+
if (!NAMESPACE.isHTML(currentNSMap['']) || !attrName.match(/^(?:disabled|checked|selected)$/i)) {
|
|
29284
|
+
errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead2!!')
|
|
29285
|
+
}
|
|
29286
|
+
addAttribute(attrName, attrName, start);
|
|
29287
|
+
start = p;
|
|
29288
|
+
s = S_ATTR;
|
|
29289
|
+
break;
|
|
29290
|
+
case S_ATTR_END:
|
|
29291
|
+
errorHandler.warning('attribute space is required"'+attrName+'"!!')
|
|
29292
|
+
case S_TAG_SPACE:
|
|
29293
|
+
s = S_ATTR;
|
|
29294
|
+
start = p;
|
|
29295
|
+
break;
|
|
29296
|
+
case S_EQ:
|
|
29297
|
+
s = S_ATTR_NOQUOT_VALUE;
|
|
29298
|
+
start = p;
|
|
29299
|
+
break;
|
|
29300
|
+
case S_TAG_CLOSE:
|
|
29301
|
+
throw new Error("elements closed character '/' and '>' must be connected to");
|
|
29302
|
+
}
|
|
29303
|
+
}
|
|
29304
|
+
}//end outer switch
|
|
29305
|
+
//console.log('p++',p)
|
|
29306
|
+
p++;
|
|
29307
|
+
}
|
|
29308
|
+
}
|
|
29309
|
+
/**
|
|
29310
|
+
* @return true if has new namespace define
|
|
29311
|
+
*/
|
|
29312
|
+
function appendElement(el,domBuilder,currentNSMap){
|
|
29313
|
+
var tagName = el.tagName;
|
|
29314
|
+
var localNSMap = null;
|
|
29315
|
+
//var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
|
|
29316
|
+
var i = el.length;
|
|
29317
|
+
while(i--){
|
|
29318
|
+
var a = el[i];
|
|
29319
|
+
var qName = a.qName;
|
|
29320
|
+
var value = a.value;
|
|
29321
|
+
var nsp = qName.indexOf(':');
|
|
29322
|
+
if(nsp>0){
|
|
29323
|
+
var prefix = a.prefix = qName.slice(0,nsp);
|
|
29324
|
+
var localName = qName.slice(nsp+1);
|
|
29325
|
+
var nsPrefix = prefix === 'xmlns' && localName
|
|
29326
|
+
}else{
|
|
29327
|
+
localName = qName;
|
|
29328
|
+
prefix = null
|
|
29329
|
+
nsPrefix = qName === 'xmlns' && ''
|
|
29330
|
+
}
|
|
29331
|
+
//can not set prefix,because prefix !== ''
|
|
29332
|
+
a.localName = localName ;
|
|
29333
|
+
//prefix == null for no ns prefix attribute
|
|
29334
|
+
if(nsPrefix !== false){//hack!!
|
|
29335
|
+
if(localNSMap == null){
|
|
29336
|
+
localNSMap = {}
|
|
29337
|
+
//console.log(currentNSMap,0)
|
|
29338
|
+
_copy(currentNSMap,currentNSMap={})
|
|
29339
|
+
//console.log(currentNSMap,1)
|
|
29340
|
+
}
|
|
29341
|
+
currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
|
|
29342
|
+
a.uri = NAMESPACE.XMLNS
|
|
29343
|
+
domBuilder.startPrefixMapping(nsPrefix, value)
|
|
29344
|
+
}
|
|
29345
|
+
}
|
|
29346
|
+
var i = el.length;
|
|
29347
|
+
while(i--){
|
|
29348
|
+
a = el[i];
|
|
29349
|
+
var prefix = a.prefix;
|
|
29350
|
+
if(prefix){//no prefix attribute has no namespace
|
|
29351
|
+
if(prefix === 'xml'){
|
|
29352
|
+
a.uri = NAMESPACE.XML;
|
|
29353
|
+
}if(prefix !== 'xmlns'){
|
|
29354
|
+
a.uri = currentNSMap[prefix || '']
|
|
29355
|
+
|
|
29356
|
+
//{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)}
|
|
29357
|
+
}
|
|
29358
|
+
}
|
|
29359
|
+
}
|
|
29360
|
+
var nsp = tagName.indexOf(':');
|
|
29361
|
+
if(nsp>0){
|
|
29362
|
+
prefix = el.prefix = tagName.slice(0,nsp);
|
|
29363
|
+
localName = el.localName = tagName.slice(nsp+1);
|
|
29364
|
+
}else{
|
|
29365
|
+
prefix = null;//important!!
|
|
29366
|
+
localName = el.localName = tagName;
|
|
29367
|
+
}
|
|
29368
|
+
//no prefix element has default namespace
|
|
29369
|
+
var ns = el.uri = currentNSMap[prefix || ''];
|
|
29370
|
+
domBuilder.startElement(ns,localName,tagName,el);
|
|
29371
|
+
//endPrefixMapping and startPrefixMapping have not any help for dom builder
|
|
29372
|
+
//localNSMap = null
|
|
29373
|
+
if(el.closed){
|
|
29374
|
+
domBuilder.endElement(ns,localName,tagName);
|
|
29375
|
+
if(localNSMap){
|
|
29376
|
+
for(prefix in localNSMap){
|
|
29377
|
+
domBuilder.endPrefixMapping(prefix)
|
|
29378
|
+
}
|
|
29379
|
+
}
|
|
29380
|
+
}else{
|
|
29381
|
+
el.currentNSMap = currentNSMap;
|
|
29382
|
+
el.localNSMap = localNSMap;
|
|
29383
|
+
//parseStack.push(el);
|
|
29384
|
+
return true;
|
|
29385
|
+
}
|
|
29386
|
+
}
|
|
29387
|
+
function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){
|
|
29388
|
+
if(/^(?:script|textarea)$/i.test(tagName)){
|
|
29389
|
+
var elEndStart = source.indexOf('</'+tagName+'>',elStartEnd);
|
|
29390
|
+
var text = source.substring(elStartEnd+1,elEndStart);
|
|
29391
|
+
if(/[&<]/.test(text)){
|
|
29392
|
+
if(/^script$/i.test(tagName)){
|
|
29393
|
+
//if(!/\]\]>/.test(text)){
|
|
29394
|
+
//lexHandler.startCDATA();
|
|
29395
|
+
domBuilder.characters(text,0,text.length);
|
|
29396
|
+
//lexHandler.endCDATA();
|
|
29397
|
+
return elEndStart;
|
|
29398
|
+
//}
|
|
29399
|
+
}//}else{//text area
|
|
29400
|
+
text = text.replace(/&#?\w+;/g,entityReplacer);
|
|
29401
|
+
domBuilder.characters(text,0,text.length);
|
|
29402
|
+
return elEndStart;
|
|
29403
|
+
//}
|
|
29404
|
+
|
|
29405
|
+
}
|
|
29406
|
+
}
|
|
29407
|
+
return elStartEnd+1;
|
|
29408
|
+
}
|
|
29409
|
+
function fixSelfClosed(source,elStartEnd,tagName,closeMap){
|
|
29410
|
+
//if(tagName in closeMap){
|
|
29411
|
+
var pos = closeMap[tagName];
|
|
29412
|
+
if(pos == null){
|
|
29413
|
+
//console.log(tagName)
|
|
29414
|
+
pos = source.lastIndexOf('</'+tagName+'>')
|
|
29415
|
+
if(pos<elStartEnd){//忘记闭合
|
|
29416
|
+
pos = source.lastIndexOf('</'+tagName)
|
|
29417
|
+
}
|
|
29418
|
+
closeMap[tagName] =pos
|
|
29419
|
+
}
|
|
29420
|
+
return pos<elStartEnd;
|
|
29421
|
+
//}
|
|
29422
|
+
}
|
|
29423
|
+
function _copy(source,target){
|
|
29424
|
+
for(var n in source){target[n] = source[n]}
|
|
29425
|
+
}
|
|
29426
|
+
function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
|
|
29427
|
+
var next= source.charAt(start+2)
|
|
29428
|
+
switch(next){
|
|
29429
|
+
case '-':
|
|
29430
|
+
if(source.charAt(start + 3) === '-'){
|
|
29431
|
+
var end = source.indexOf('-->',start+4);
|
|
29432
|
+
//append comment source.substring(4,end)//<!--
|
|
29433
|
+
if(end>start){
|
|
29434
|
+
domBuilder.comment(source,start+4,end-start-4);
|
|
29435
|
+
return end+3;
|
|
29436
|
+
}else{
|
|
29437
|
+
errorHandler.error("Unclosed comment");
|
|
29438
|
+
return -1;
|
|
29439
|
+
}
|
|
29440
|
+
}else{
|
|
29441
|
+
//error
|
|
29442
|
+
return -1;
|
|
29443
|
+
}
|
|
29444
|
+
default:
|
|
29445
|
+
if(source.substr(start+3,6) == 'CDATA['){
|
|
29446
|
+
var end = source.indexOf(']]>',start+9);
|
|
29447
|
+
domBuilder.startCDATA();
|
|
29448
|
+
domBuilder.characters(source,start+9,end-start-9);
|
|
29449
|
+
domBuilder.endCDATA()
|
|
29450
|
+
return end+3;
|
|
29451
|
+
}
|
|
29452
|
+
//<!DOCTYPE
|
|
29453
|
+
//startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
|
|
29454
|
+
var matchs = split(source,start);
|
|
29455
|
+
var len = matchs.length;
|
|
29456
|
+
if(len>1 && /!doctype/i.test(matchs[0][0])){
|
|
29457
|
+
var name = matchs[1][0];
|
|
29458
|
+
var pubid = false;
|
|
29459
|
+
var sysid = false;
|
|
29460
|
+
if(len>3){
|
|
29461
|
+
if(/^public$/i.test(matchs[2][0])){
|
|
29462
|
+
pubid = matchs[3][0];
|
|
29463
|
+
sysid = len>4 && matchs[4][0];
|
|
29464
|
+
}else if(/^system$/i.test(matchs[2][0])){
|
|
29465
|
+
sysid = matchs[3][0];
|
|
29466
|
+
}
|
|
29467
|
+
}
|
|
29468
|
+
var lastMatch = matchs[len-1]
|
|
29469
|
+
domBuilder.startDTD(name, pubid, sysid);
|
|
29470
|
+
domBuilder.endDTD();
|
|
29471
|
+
|
|
29472
|
+
return lastMatch.index+lastMatch[0].length
|
|
29473
|
+
}
|
|
29474
|
+
}
|
|
29475
|
+
return -1;
|
|
29476
|
+
}
|
|
29477
|
+
|
|
29478
|
+
|
|
29479
|
+
|
|
29480
|
+
function parseInstruction(source,start,domBuilder){
|
|
29481
|
+
var end = source.indexOf('?>',start);
|
|
29482
|
+
if(end){
|
|
29483
|
+
var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
|
|
29484
|
+
if(match){
|
|
29485
|
+
var len = match[0].length;
|
|
29486
|
+
domBuilder.processingInstruction(match[1], match[2]) ;
|
|
29487
|
+
return end+2;
|
|
29488
|
+
}else{//error
|
|
29489
|
+
return -1;
|
|
29490
|
+
}
|
|
29491
|
+
}
|
|
29492
|
+
return -1;
|
|
29493
|
+
}
|
|
29494
|
+
|
|
29495
|
+
function ElementAttributes(){
|
|
29496
|
+
this.attributeNames = {}
|
|
29497
|
+
}
|
|
29498
|
+
ElementAttributes.prototype = {
|
|
29499
|
+
setTagName:function(tagName){
|
|
29500
|
+
if(!tagNamePattern.test(tagName)){
|
|
29501
|
+
throw new Error('invalid tagName:'+tagName)
|
|
29502
|
+
}
|
|
29503
|
+
this.tagName = tagName
|
|
29504
|
+
},
|
|
29505
|
+
addValue:function(qName, value, offset) {
|
|
29506
|
+
if(!tagNamePattern.test(qName)){
|
|
29507
|
+
throw new Error('invalid attribute:'+qName)
|
|
29508
|
+
}
|
|
29509
|
+
this.attributeNames[qName] = this.length;
|
|
29510
|
+
this[this.length++] = {qName:qName,value:value,offset:offset}
|
|
29511
|
+
},
|
|
29512
|
+
length:0,
|
|
29513
|
+
getLocalName:function(i){return this[i].localName},
|
|
29514
|
+
getLocator:function(i){return this[i].locator},
|
|
29515
|
+
getQName:function(i){return this[i].qName},
|
|
29516
|
+
getURI:function(i){return this[i].uri},
|
|
29517
|
+
getValue:function(i){return this[i].value}
|
|
29518
|
+
// ,getIndex:function(uri, localName)){
|
|
29519
|
+
// if(localName){
|
|
29520
|
+
//
|
|
29521
|
+
// }else{
|
|
29522
|
+
// var qName = uri
|
|
29523
|
+
// }
|
|
29524
|
+
// },
|
|
29525
|
+
// getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
|
|
29526
|
+
// getType:function(uri,localName){}
|
|
29527
|
+
// getType:function(i){},
|
|
29528
|
+
}
|
|
29529
|
+
|
|
29530
|
+
|
|
29531
|
+
|
|
29532
|
+
function split(source,start){
|
|
29533
|
+
var match;
|
|
29534
|
+
var buf = [];
|
|
29535
|
+
var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
|
|
29536
|
+
reg.lastIndex = start;
|
|
29537
|
+
reg.exec(source);//skip <
|
|
29538
|
+
while(match = reg.exec(source)){
|
|
29539
|
+
buf.push(match);
|
|
29540
|
+
if(match[1])return buf;
|
|
29541
|
+
}
|
|
29542
|
+
}
|
|
29543
|
+
|
|
29544
|
+
exports.XMLReader = XMLReader;
|
|
29545
|
+
exports.ParseError = ParseError;
|
|
29546
|
+
|
|
29547
|
+
|
|
26261
29548
|
/***/ }),
|
|
26262
29549
|
|
|
26263
29550
|
/***/ "./node_modules/async/dist/async.mjs":
|
|
@@ -61583,10 +64870,11 @@ var XMLHandler = /*#__PURE__*/function (_Handler3) {
|
|
|
61583
64870
|
// figure out the root element
|
|
61584
64871
|
|
|
61585
64872
|
for (var c = 0; c < dom.childNodes.length; c++) {
|
|
61586
|
-
// is this node an element?
|
|
61587
|
-
|
|
64873
|
+
var node = dom.childNodes[c]; // is this node an element?
|
|
64874
|
+
|
|
64875
|
+
if (XMLHandler.isElement(node)) {
|
|
61588
64876
|
// We've found the first element, it's the root
|
|
61589
|
-
var _ns =
|
|
64877
|
+
var _ns = node.namespaceURI; // Is it RDF/XML?
|
|
61590
64878
|
|
|
61591
64879
|
if (_ns && _ns === _ns['rdf']) {
|
|
61592
64880
|
fetcher.addStatus(options.req, 'Has XML root element in the RDF namespace, so assume RDF/XML.');
|
|
@@ -61646,6 +64934,11 @@ var XMLHandler = /*#__PURE__*/function (_Handler3) {
|
|
|
61646
64934
|
'q': 0.5
|
|
61647
64935
|
};
|
|
61648
64936
|
}
|
|
64937
|
+
}, {
|
|
64938
|
+
key: "isElement",
|
|
64939
|
+
value: function isElement(node) {
|
|
64940
|
+
return node.nodeType === Node.ELEMENT_NODE;
|
|
64941
|
+
}
|
|
61649
64942
|
}]);
|
|
61650
64943
|
|
|
61651
64944
|
return XMLHandler;
|
|
@@ -75629,8 +78922,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
75629
78922
|
|
|
75630
78923
|
/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "uri", function() { return _uri__WEBPACK_IMPORTED_MODULE_0__; });
|
|
75631
78924
|
/* harmony import */ var _named_node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./named-node */ "./node_modules/rdflib/esm/named-node.js");
|
|
75632
|
-
/* harmony import */ var
|
|
75633
|
-
/* harmony import */ var
|
|
78925
|
+
/* harmony import */ var _xmldom_xmldom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @xmldom/xmldom */ "./node_modules/@xmldom/xmldom/lib/index.js");
|
|
78926
|
+
/* harmony import */ var _xmldom_xmldom__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_xmldom_xmldom__WEBPACK_IMPORTED_MODULE_3__);
|
|
75634
78927
|
/**
|
|
75635
78928
|
* Utility functions for $rdf
|
|
75636
78929
|
* @module util
|
|
@@ -75725,7 +79018,7 @@ function callbackify(obj, callbacks) {
|
|
|
75725
79018
|
|
|
75726
79019
|
function DOMParserFactory() {
|
|
75727
79020
|
if (window.DOMParser) {
|
|
75728
|
-
return new
|
|
79021
|
+
return new _xmldom_xmldom__WEBPACK_IMPORTED_MODULE_3__["DOMParser"]();
|
|
75729
79022
|
} else if (window.ActiveXObject) {
|
|
75730
79023
|
return new ActiveXObject('Microsoft.XMLDOM');
|
|
75731
79024
|
} else {
|
|
@@ -75888,7 +79181,7 @@ function output(o) {
|
|
|
75888
79181
|
}
|
|
75889
79182
|
|
|
75890
79183
|
/**
|
|
75891
|
-
* Returns a DOM from
|
|
79184
|
+
* Returns a DOM from parsed XML.
|
|
75892
79185
|
*/
|
|
75893
79186
|
|
|
75894
79187
|
function parseXML(str, options) {
|
|
@@ -75897,13 +79190,13 @@ function parseXML(str, options) {
|
|
|
75897
79190
|
|
|
75898
79191
|
if ( true && module && module.exports) {
|
|
75899
79192
|
// Node.js
|
|
75900
|
-
var dom = new
|
|
79193
|
+
var dom = new _xmldom_xmldom__WEBPACK_IMPORTED_MODULE_3__["DOMParser"]().parseFromString(str, options.contentType || 'application/xhtml+xml');
|
|
75901
79194
|
return dom;
|
|
75902
79195
|
} else {
|
|
75903
79196
|
if (typeof window !== 'undefined' && window.DOMParser) {
|
|
75904
79197
|
dparser = new window.DOMParser(); // seems to actually work
|
|
75905
79198
|
} else {
|
|
75906
|
-
dparser = new
|
|
79199
|
+
dparser = new _xmldom_xmldom__WEBPACK_IMPORTED_MODULE_3__["DOMParser"](); // Doc says this works
|
|
75907
79200
|
}
|
|
75908
79201
|
}
|
|
75909
79202
|
|
|
@@ -83994,17 +87287,6 @@ try {
|
|
|
83994
87287
|
|
|
83995
87288
|
/* (ignored) */
|
|
83996
87289
|
|
|
83997
|
-
/***/ }),
|
|
83998
|
-
|
|
83999
|
-
/***/ "xmldom":
|
|
84000
|
-
/*!*************************!*\
|
|
84001
|
-
!*** external "window" ***!
|
|
84002
|
-
\*************************/
|
|
84003
|
-
/*! no static exports found */
|
|
84004
|
-
/***/ (function(module, exports) {
|
|
84005
|
-
|
|
84006
|
-
module.exports = window;
|
|
84007
|
-
|
|
84008
87290
|
/***/ })
|
|
84009
87291
|
|
|
84010
87292
|
/******/ });
|