msw 0.33.1 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/RequestHandler-deps.js +78 -21
- package/lib/esm/graphql-deps.js +34 -13
- package/lib/esm/index.js +526 -125
- package/lib/esm/mockServiceWorker.js +18 -9
- package/lib/esm/rest-deps.js +3 -2
- package/lib/iife/index.js +3 -3
- package/lib/iife/mockServiceWorker.js +18 -9
- package/lib/types/graphql.d.ts +13 -4
- package/lib/types/handlers/GraphQLHandler.d.ts +3 -2
- package/lib/types/node/glossary.d.ts +4 -14
- package/lib/types/setupWorker/glossary.d.ts +4 -14
- package/lib/types/sharedOptions.d.ts +11 -0
- package/lib/types/utils/internal/parseGraphQLRequest.d.ts +2 -1
- package/lib/types/utils/internal/pipeEvents.d.ts +6 -0
- package/lib/types/utils/logging/getStatusCodeColor.d.ts +6 -1
- package/lib/umd/index.js +652 -159
- package/lib/umd/mockServiceWorker.js +18 -9
- package/native/lib/index.js +145 -36
- package/node/lib/index.js +145 -36
- package/package.json +3 -3
package/lib/umd/index.js
CHANGED
|
@@ -1754,6 +1754,65 @@
|
|
|
1754
1754
|
|
|
1755
1755
|
var invariant$3 = {};
|
|
1756
1756
|
|
|
1757
|
+
var format$1 = {};
|
|
1758
|
+
|
|
1759
|
+
Object.defineProperty(format$1, "__esModule", { value: true });
|
|
1760
|
+
format$1.format = void 0;
|
|
1761
|
+
var POSITIONALS_EXP = /(%?)(%([sdjo]))/g;
|
|
1762
|
+
function serializePositional(positional, flag) {
|
|
1763
|
+
switch (flag) {
|
|
1764
|
+
// Strings.
|
|
1765
|
+
case 's':
|
|
1766
|
+
return positional;
|
|
1767
|
+
// Digits.
|
|
1768
|
+
case 'd':
|
|
1769
|
+
case 'i':
|
|
1770
|
+
return Number(positional);
|
|
1771
|
+
// JSON.
|
|
1772
|
+
case 'j':
|
|
1773
|
+
return JSON.stringify(positional);
|
|
1774
|
+
// Objects.
|
|
1775
|
+
case 'o': {
|
|
1776
|
+
// Preserve stings to prevent extra quotes around them.
|
|
1777
|
+
if (typeof positional === 'string') {
|
|
1778
|
+
return positional;
|
|
1779
|
+
}
|
|
1780
|
+
var json = JSON.stringify(positional);
|
|
1781
|
+
// If the positional isn't serializable, return it as-is.
|
|
1782
|
+
if (json === '{}' || json === '[]' || /^\[object .+?\]$/.test(json)) {
|
|
1783
|
+
return positional;
|
|
1784
|
+
}
|
|
1785
|
+
return json;
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
function format(message) {
|
|
1790
|
+
var positionals = [];
|
|
1791
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1792
|
+
positionals[_i - 1] = arguments[_i];
|
|
1793
|
+
}
|
|
1794
|
+
if (positionals.length === 0) {
|
|
1795
|
+
return message;
|
|
1796
|
+
}
|
|
1797
|
+
var positionalIndex = 0;
|
|
1798
|
+
var formattedMessage = message.replace(POSITIONALS_EXP, function (match, isEscaped, _, flag) {
|
|
1799
|
+
var positional = positionals[positionalIndex];
|
|
1800
|
+
var value = serializePositional(positional, flag);
|
|
1801
|
+
if (!isEscaped) {
|
|
1802
|
+
positionalIndex++;
|
|
1803
|
+
return value;
|
|
1804
|
+
}
|
|
1805
|
+
return match;
|
|
1806
|
+
});
|
|
1807
|
+
// Append unresolved positionals to string as-is.
|
|
1808
|
+
if (positionalIndex < positionals.length) {
|
|
1809
|
+
formattedMessage += " " + positionals.slice(positionalIndex).join(' ');
|
|
1810
|
+
}
|
|
1811
|
+
formattedMessage = formattedMessage.replace(/%{2,2}/g, '%');
|
|
1812
|
+
return formattedMessage;
|
|
1813
|
+
}
|
|
1814
|
+
format$1.format = format;
|
|
1815
|
+
|
|
1757
1816
|
var __extends$1 = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
|
|
1758
1817
|
var extendStatics = function (d, b) {
|
|
1759
1818
|
extendStatics = Object.setPrototypeOf ||
|
|
@@ -1775,21 +1834,9 @@
|
|
|
1775
1834
|
return to;
|
|
1776
1835
|
};
|
|
1777
1836
|
Object.defineProperty(invariant$3, "__esModule", { value: true });
|
|
1778
|
-
invariant$3.invariant = invariant$3.InvariantError =
|
|
1837
|
+
invariant$3.invariant = invariant$3.InvariantError = void 0;
|
|
1838
|
+
var format_1 = format$1;
|
|
1779
1839
|
var STACK_FRAMES_TO_IGNORE = 2;
|
|
1780
|
-
function interpolate(message) {
|
|
1781
|
-
var positionals = [];
|
|
1782
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1783
|
-
positionals[_i - 1] = arguments[_i];
|
|
1784
|
-
}
|
|
1785
|
-
var index = 0;
|
|
1786
|
-
return message.replace(/%[s|d|o]/g, function (match) {
|
|
1787
|
-
var _a;
|
|
1788
|
-
var value = (_a = positionals[index++]) !== null && _a !== void 0 ? _a : match;
|
|
1789
|
-
return typeof value === 'object' ? JSON.stringify(value) : value;
|
|
1790
|
-
});
|
|
1791
|
-
}
|
|
1792
|
-
invariant$3.interpolate = interpolate;
|
|
1793
1840
|
var InvariantError = /** @class */ (function (_super) {
|
|
1794
1841
|
__extends$1(InvariantError, _super);
|
|
1795
1842
|
function InvariantError(message) {
|
|
@@ -1799,7 +1846,7 @@
|
|
|
1799
1846
|
}
|
|
1800
1847
|
var _this = _super.call(this, message) || this;
|
|
1801
1848
|
_this.name = 'Invariant Violation';
|
|
1802
|
-
_this.message =
|
|
1849
|
+
_this.message = format_1.format.apply(void 0, __spreadArray([message], positionals));
|
|
1803
1850
|
if (_this.stack) {
|
|
1804
1851
|
var prevStack = _this.stack;
|
|
1805
1852
|
_this.stack = prevStack
|
|
@@ -1836,6 +1883,7 @@
|
|
|
1836
1883
|
};
|
|
1837
1884
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1838
1885
|
__exportStar(invariant$3, exports);
|
|
1886
|
+
__exportStar(format$1, exports);
|
|
1839
1887
|
}(lib$2));
|
|
1840
1888
|
|
|
1841
1889
|
const LIBRARY_PREFIX = '[MSW]';
|
|
@@ -1843,7 +1891,7 @@
|
|
|
1843
1891
|
* Formats a given message by appending the library's prefix string.
|
|
1844
1892
|
*/
|
|
1845
1893
|
function formatMessage(message, ...positionals) {
|
|
1846
|
-
const interpolatedMessage = lib$2.
|
|
1894
|
+
const interpolatedMessage = lib$2.format(message, ...positionals);
|
|
1847
1895
|
return `${LIBRARY_PREFIX} ${interpolatedMessage}`;
|
|
1848
1896
|
}
|
|
1849
1897
|
/**
|
|
@@ -22235,17 +22283,20 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
22235
22283
|
: new URL(request.url.pathname, `${request.url.protocol}//${request.url.host}`).href;
|
|
22236
22284
|
};
|
|
22237
22285
|
|
|
22238
|
-
function
|
|
22286
|
+
function parseDocumentNode(node) {
|
|
22239
22287
|
var _a;
|
|
22288
|
+
const operationDef = node.definitions.find((def) => {
|
|
22289
|
+
return def.kind === 'OperationDefinition';
|
|
22290
|
+
});
|
|
22291
|
+
return {
|
|
22292
|
+
operationType: operationDef === null || operationDef === void 0 ? void 0 : operationDef.operation,
|
|
22293
|
+
operationName: (_a = operationDef === null || operationDef === void 0 ? void 0 : operationDef.name) === null || _a === void 0 ? void 0 : _a.value,
|
|
22294
|
+
};
|
|
22295
|
+
}
|
|
22296
|
+
function parseQuery(query) {
|
|
22240
22297
|
try {
|
|
22241
22298
|
const ast = graphql$3.parse(query);
|
|
22242
|
-
|
|
22243
|
-
return def.kind === 'OperationDefinition';
|
|
22244
|
-
});
|
|
22245
|
-
return {
|
|
22246
|
-
operationType: operationDef === null || operationDef === void 0 ? void 0 : operationDef.operation,
|
|
22247
|
-
operationName: (_a = operationDef === null || operationDef === void 0 ? void 0 : operationDef.name) === null || _a === void 0 ? void 0 : _a.value,
|
|
22248
|
-
};
|
|
22299
|
+
return parseDocumentNode(ast);
|
|
22249
22300
|
}
|
|
22250
22301
|
catch (error) {
|
|
22251
22302
|
return error;
|
|
@@ -22325,7 +22376,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
22325
22376
|
const parsedResult = parseQuery(query);
|
|
22326
22377
|
if (parsedResult instanceof Error) {
|
|
22327
22378
|
const requestPublicUrl = getPublicUrlFromRequest(request);
|
|
22328
|
-
throw new Error(devUtils.formatMessage('Failed to intercept a GraphQL request to "%s %s": cannot parse query. See the error message from the parser below.\n\n%
|
|
22379
|
+
throw new Error(devUtils.formatMessage('Failed to intercept a GraphQL request to "%s %s": cannot parse query. See the error message from the parser below.\n\n%s', request.method, requestPublicUrl, parsedResult.message));
|
|
22329
22380
|
}
|
|
22330
22381
|
return {
|
|
22331
22382
|
operationType: parsedResult.operationType,
|
|
@@ -22334,17 +22385,23 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
22334
22385
|
};
|
|
22335
22386
|
}
|
|
22336
22387
|
|
|
22388
|
+
var StatusCodeColor;
|
|
22389
|
+
(function (StatusCodeColor) {
|
|
22390
|
+
StatusCodeColor["Success"] = "#69AB32";
|
|
22391
|
+
StatusCodeColor["Warning"] = "#F0BB4B";
|
|
22392
|
+
StatusCodeColor["Danger"] = "#E95F5D";
|
|
22393
|
+
})(StatusCodeColor || (StatusCodeColor = {}));
|
|
22337
22394
|
/**
|
|
22338
22395
|
* Returns a HEX color for a given response status code number.
|
|
22339
22396
|
*/
|
|
22340
22397
|
function getStatusCodeColor(status) {
|
|
22341
22398
|
if (status < 300) {
|
|
22342
|
-
return
|
|
22399
|
+
return StatusCodeColor.Success;
|
|
22343
22400
|
}
|
|
22344
22401
|
if (status < 400) {
|
|
22345
|
-
return
|
|
22402
|
+
return StatusCodeColor.Warning;
|
|
22346
22403
|
}
|
|
22347
|
-
return
|
|
22404
|
+
return StatusCodeColor.Danger;
|
|
22348
22405
|
}
|
|
22349
22406
|
|
|
22350
22407
|
/**
|
|
@@ -22457,7 +22514,10 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
22457
22514
|
// Resolve a relative request URL against a given custom "baseUrl"
|
|
22458
22515
|
// or the current location (in the case of browser/browser-like environments).
|
|
22459
22516
|
const origin = baseUrl || (typeof location !== 'undefined' && location.origin);
|
|
22460
|
-
return origin
|
|
22517
|
+
return origin
|
|
22518
|
+
? // Encode and decode the path to preserve escaped characters.
|
|
22519
|
+
decodeURI(new URL(encodeURI(path), origin).href)
|
|
22520
|
+
: path;
|
|
22461
22521
|
}
|
|
22462
22522
|
|
|
22463
22523
|
/**
|
|
@@ -22730,7 +22790,8 @@ ${queryParams
|
|
|
22730
22790
|
const publicUrl = getPublicUrlFromRequest(request);
|
|
22731
22791
|
const loggedRequest = prepareRequest(request);
|
|
22732
22792
|
const loggedResponse = prepareResponse(response);
|
|
22733
|
-
|
|
22793
|
+
const statusColor = getStatusCodeColor(response.status);
|
|
22794
|
+
console.groupCollapsed(devUtils.formatMessage('%s %s %s (%c%s%c)'), getTimestamp(), request.method, publicUrl, `color:${statusColor}`, `${response.status} ${response.statusText}`, 'color:inherit');
|
|
22734
22795
|
console.log('Request', loggedRequest);
|
|
22735
22796
|
console.log('Handler:', {
|
|
22736
22797
|
mask: this.info.path,
|
|
@@ -22760,16 +22821,33 @@ ${queryParams
|
|
|
22760
22821
|
errors,
|
|
22761
22822
|
cookie,
|
|
22762
22823
|
};
|
|
22824
|
+
function isDocumentNode(value) {
|
|
22825
|
+
if (value == null) {
|
|
22826
|
+
return false;
|
|
22827
|
+
}
|
|
22828
|
+
return typeof value === 'object' && 'kind' in value && 'definitions' in value;
|
|
22829
|
+
}
|
|
22763
22830
|
class GraphQLHandler extends RequestHandler {
|
|
22764
22831
|
constructor(operationType, operationName, endpoint, resolver) {
|
|
22832
|
+
let resolvedOperationName = operationName;
|
|
22833
|
+
if (isDocumentNode(operationName)) {
|
|
22834
|
+
const parsedNode = parseDocumentNode(operationName);
|
|
22835
|
+
if (parsedNode.operationType !== operationType) {
|
|
22836
|
+
throw new Error(`Failed to create a GraphQL handler: provided a DocumentNode with a mismatched operation type (expected "${operationType}", but got "${parsedNode.operationType}").`);
|
|
22837
|
+
}
|
|
22838
|
+
if (!parsedNode.operationName) {
|
|
22839
|
+
throw new Error(`Failed to create a GraphQL handler: provided a DocumentNode with no operation name.`);
|
|
22840
|
+
}
|
|
22841
|
+
resolvedOperationName = parsedNode.operationName;
|
|
22842
|
+
}
|
|
22765
22843
|
const header = operationType === 'all'
|
|
22766
22844
|
? `${operationType} (origin: ${endpoint.toString()})`
|
|
22767
|
-
: `${operationType} ${
|
|
22845
|
+
: `${operationType} ${resolvedOperationName} (origin: ${endpoint.toString()})`;
|
|
22768
22846
|
super({
|
|
22769
22847
|
info: {
|
|
22770
22848
|
header,
|
|
22771
22849
|
operationType,
|
|
22772
|
-
operationName,
|
|
22850
|
+
operationName: resolvedOperationName,
|
|
22773
22851
|
},
|
|
22774
22852
|
ctx: graphqlContext,
|
|
22775
22853
|
resolver,
|
|
@@ -22808,7 +22886,8 @@ Consider naming this operation or using "graphql.operation" request handler to i
|
|
|
22808
22886
|
log(request, response, handler, parsedRequest) {
|
|
22809
22887
|
const loggedRequest = prepareRequest(request);
|
|
22810
22888
|
const loggedResponse = prepareResponse(response);
|
|
22811
|
-
|
|
22889
|
+
const statusColor = getStatusCodeColor(response.status);
|
|
22890
|
+
console.groupCollapsed(devUtils.formatMessage('%s %s (%c%s%c)'), getTimestamp(), `${parsedRequest === null || parsedRequest === void 0 ? void 0 : parsedRequest.operationType} ${parsedRequest === null || parsedRequest === void 0 ? void 0 : parsedRequest.operationName}`, `color:${statusColor}`, `${response.status} ${response.statusText}`, 'color:inherit');
|
|
22812
22891
|
console.log('Request:', loggedRequest);
|
|
22813
22892
|
console.log('Handler:', this);
|
|
22814
22893
|
console.log('Response:', loggedResponse);
|
|
@@ -22922,8 +23001,10 @@ Read more: https://mswjs.io/docs/getting-started/mocks\
|
|
|
22922
23001
|
const message = messageTemplate.join('\n\n');
|
|
22923
23002
|
switch (strategy) {
|
|
22924
23003
|
case 'error': {
|
|
23004
|
+
// Print a developer-friendly error.
|
|
22925
23005
|
devUtils.error('Error: %s', message);
|
|
22926
|
-
|
|
23006
|
+
// Throw an exception to halt request processing and not perform the original request.
|
|
23007
|
+
throw new Error('Cannot bypass a request when using the "error" strategy for the "onUnhandledRequest" option.');
|
|
22927
23008
|
}
|
|
22928
23009
|
case 'warn': {
|
|
22929
23010
|
devUtils.warn('Warning: %s', message);
|
|
@@ -23053,8 +23134,8 @@ Read more: https://mswjs.io/docs/getting-started/mocks\
|
|
|
23053
23134
|
const { payload: actualChecksum } = yield context.events.once('INTEGRITY_CHECK_RESPONSE');
|
|
23054
23135
|
// Compare the response from the Service Worker and the
|
|
23055
23136
|
// global variable set by Rollup during the build.
|
|
23056
|
-
if (actualChecksum !== "
|
|
23057
|
-
throw new Error(`Currently active Service Worker (${actualChecksum}) is behind the latest published one (${"
|
|
23137
|
+
if (actualChecksum !== "f0a916b13c8acc2b526a03a6d26df85f") {
|
|
23138
|
+
throw new Error(`Currently active Service Worker (${actualChecksum}) is behind the latest published one (${"f0a916b13c8acc2b526a03a6d26df85f"}).`);
|
|
23058
23139
|
}
|
|
23059
23140
|
return serviceWorker;
|
|
23060
23141
|
});
|
|
@@ -23203,16 +23284,14 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
23203
23284
|
}
|
|
23204
23285
|
|
|
23205
23286
|
const createStop = (context) => {
|
|
23206
|
-
/**
|
|
23207
|
-
* Signal the Service Worker to disable mocking for this client.
|
|
23208
|
-
* Use this an an explicit way to stop the mocking, while preserving
|
|
23209
|
-
* the worker-client relation. Does not affect the worker's lifecycle.
|
|
23210
|
-
*/
|
|
23211
23287
|
return function stop() {
|
|
23212
23288
|
var _a;
|
|
23289
|
+
/**
|
|
23290
|
+
* Signal the Service Worker to disable mocking for this client.
|
|
23291
|
+
* Use this an an explicit way to stop the mocking, while preserving
|
|
23292
|
+
* the worker-client relation. Does not affect the worker's lifecycle.
|
|
23293
|
+
*/
|
|
23213
23294
|
context.workerChannel.send('MOCK_DEACTIVATE');
|
|
23214
|
-
context.events.removeAllListeners();
|
|
23215
|
-
context.emitter.removeAllListeners();
|
|
23216
23295
|
window.clearInterval(context.keepAliveInterval);
|
|
23217
23296
|
printStopMessage({ quiet: (_a = context.startOptions) === null || _a === void 0 ? void 0 : _a.quiet });
|
|
23218
23297
|
};
|
|
@@ -23745,6 +23824,8 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
23745
23824
|
function createDebug(namespace) {
|
|
23746
23825
|
let prevTime;
|
|
23747
23826
|
let enableOverride = null;
|
|
23827
|
+
let namespacesCache;
|
|
23828
|
+
let enabledCache;
|
|
23748
23829
|
|
|
23749
23830
|
function debug(...args) {
|
|
23750
23831
|
// Disabled?
|
|
@@ -23805,7 +23886,17 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
23805
23886
|
Object.defineProperty(debug, 'enabled', {
|
|
23806
23887
|
enumerable: true,
|
|
23807
23888
|
configurable: false,
|
|
23808
|
-
get: () =>
|
|
23889
|
+
get: () => {
|
|
23890
|
+
if (enableOverride !== null) {
|
|
23891
|
+
return enableOverride;
|
|
23892
|
+
}
|
|
23893
|
+
if (namespacesCache !== createDebug.namespaces) {
|
|
23894
|
+
namespacesCache = createDebug.namespaces;
|
|
23895
|
+
enabledCache = createDebug.enabled(namespace);
|
|
23896
|
+
}
|
|
23897
|
+
|
|
23898
|
+
return enabledCache;
|
|
23899
|
+
},
|
|
23809
23900
|
set: v => {
|
|
23810
23901
|
enableOverride = v;
|
|
23811
23902
|
}
|
|
@@ -23834,6 +23925,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
23834
23925
|
*/
|
|
23835
23926
|
function enable(namespaces) {
|
|
23836
23927
|
createDebug.save(namespaces);
|
|
23928
|
+
createDebug.namespaces = namespaces;
|
|
23837
23929
|
|
|
23838
23930
|
createDebug.names = [];
|
|
23839
23931
|
createDebug.skips = [];
|
|
@@ -24361,9 +24453,179 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
24361
24453
|
|
|
24362
24454
|
var domParser = {};
|
|
24363
24455
|
|
|
24364
|
-
var
|
|
24456
|
+
var conventions$2 = {};
|
|
24457
|
+
|
|
24458
|
+
/**
|
|
24459
|
+
* "Shallow freezes" an object to render it immutable.
|
|
24460
|
+
* Uses `Object.freeze` if available,
|
|
24461
|
+
* otherwise the immutability is only in the type.
|
|
24462
|
+
*
|
|
24463
|
+
* Is used to create "enum like" objects.
|
|
24464
|
+
*
|
|
24465
|
+
* @template T
|
|
24466
|
+
* @param {T} object the object to freeze
|
|
24467
|
+
* @param {Pick<ObjectConstructor, 'freeze'> = Object} oc `Object` by default,
|
|
24468
|
+
* allows to inject custom object constructor for tests
|
|
24469
|
+
* @returns {Readonly<T>}
|
|
24470
|
+
*
|
|
24471
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
|
|
24472
|
+
*/
|
|
24473
|
+
function freeze(object, oc) {
|
|
24474
|
+
if (oc === undefined) {
|
|
24475
|
+
oc = Object;
|
|
24476
|
+
}
|
|
24477
|
+
return oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object
|
|
24478
|
+
}
|
|
24479
|
+
|
|
24480
|
+
/**
|
|
24481
|
+
* All mime types that are allowed as input to `DOMParser.parseFromString`
|
|
24482
|
+
*
|
|
24483
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02 MDN
|
|
24484
|
+
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype WHATWG HTML Spec
|
|
24485
|
+
* @see DOMParser.prototype.parseFromString
|
|
24486
|
+
*/
|
|
24487
|
+
var MIME_TYPE = freeze({
|
|
24488
|
+
/**
|
|
24489
|
+
* `text/html`, the only mime type that triggers treating an XML document as HTML.
|
|
24490
|
+
*
|
|
24491
|
+
* @see DOMParser.SupportedType.isHTML
|
|
24492
|
+
* @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
|
|
24493
|
+
* @see https://en.wikipedia.org/wiki/HTML Wikipedia
|
|
24494
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
|
|
24495
|
+
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring WHATWG HTML Spec
|
|
24496
|
+
*/
|
|
24497
|
+
HTML: 'text/html',
|
|
24498
|
+
|
|
24499
|
+
/**
|
|
24500
|
+
* Helper method to check a mime type if it indicates an HTML document
|
|
24501
|
+
*
|
|
24502
|
+
* @param {string} [value]
|
|
24503
|
+
* @returns {boolean}
|
|
24504
|
+
*
|
|
24505
|
+
* @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
|
|
24506
|
+
* @see https://en.wikipedia.org/wiki/HTML Wikipedia
|
|
24507
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
|
|
24508
|
+
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring */
|
|
24509
|
+
isHTML: function (value) {
|
|
24510
|
+
return value === MIME_TYPE.HTML
|
|
24511
|
+
},
|
|
24512
|
+
|
|
24513
|
+
/**
|
|
24514
|
+
* `application/xml`, the standard mime type for XML documents.
|
|
24515
|
+
*
|
|
24516
|
+
* @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType registration
|
|
24517
|
+
* @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303
|
|
24518
|
+
* @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
|
|
24519
|
+
*/
|
|
24520
|
+
XML_APPLICATION: 'application/xml',
|
|
24521
|
+
|
|
24522
|
+
/**
|
|
24523
|
+
* `text/html`, an alias for `application/xml`.
|
|
24524
|
+
*
|
|
24525
|
+
* @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303
|
|
24526
|
+
* @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration
|
|
24527
|
+
* @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
|
|
24528
|
+
*/
|
|
24529
|
+
XML_TEXT: 'text/xml',
|
|
24530
|
+
|
|
24531
|
+
/**
|
|
24532
|
+
* `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,
|
|
24533
|
+
* but is parsed as an XML document.
|
|
24534
|
+
*
|
|
24535
|
+
* @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType registration
|
|
24536
|
+
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec
|
|
24537
|
+
* @see https://en.wikipedia.org/wiki/XHTML Wikipedia
|
|
24538
|
+
*/
|
|
24539
|
+
XML_XHTML_APPLICATION: 'application/xhtml+xml',
|
|
24540
|
+
|
|
24541
|
+
/**
|
|
24542
|
+
* `image/svg+xml`,
|
|
24543
|
+
*
|
|
24544
|
+
* @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration
|
|
24545
|
+
* @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1
|
|
24546
|
+
* @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia
|
|
24547
|
+
*/
|
|
24548
|
+
XML_SVG_IMAGE: 'image/svg+xml',
|
|
24549
|
+
});
|
|
24365
24550
|
|
|
24366
|
-
|
|
24551
|
+
/**
|
|
24552
|
+
* Namespaces that are used in this code base.
|
|
24553
|
+
*
|
|
24554
|
+
* @see http://www.w3.org/TR/REC-xml-names
|
|
24555
|
+
*/
|
|
24556
|
+
var NAMESPACE$3 = freeze({
|
|
24557
|
+
/**
|
|
24558
|
+
* The XHTML namespace.
|
|
24559
|
+
*
|
|
24560
|
+
* @see http://www.w3.org/1999/xhtml
|
|
24561
|
+
*/
|
|
24562
|
+
HTML: 'http://www.w3.org/1999/xhtml',
|
|
24563
|
+
|
|
24564
|
+
/**
|
|
24565
|
+
* Checks if `uri` equals `NAMESPACE.HTML`.
|
|
24566
|
+
*
|
|
24567
|
+
* @param {string} [uri]
|
|
24568
|
+
*
|
|
24569
|
+
* @see NAMESPACE.HTML
|
|
24570
|
+
*/
|
|
24571
|
+
isHTML: function (uri) {
|
|
24572
|
+
return uri === NAMESPACE$3.HTML
|
|
24573
|
+
},
|
|
24574
|
+
|
|
24575
|
+
/**
|
|
24576
|
+
* The SVG namespace.
|
|
24577
|
+
*
|
|
24578
|
+
* @see http://www.w3.org/2000/svg
|
|
24579
|
+
*/
|
|
24580
|
+
SVG: 'http://www.w3.org/2000/svg',
|
|
24581
|
+
|
|
24582
|
+
/**
|
|
24583
|
+
* The `xml:` namespace.
|
|
24584
|
+
*
|
|
24585
|
+
* @see http://www.w3.org/XML/1998/namespace
|
|
24586
|
+
*/
|
|
24587
|
+
XML: 'http://www.w3.org/XML/1998/namespace',
|
|
24588
|
+
|
|
24589
|
+
/**
|
|
24590
|
+
* The `xmlns:` namespace
|
|
24591
|
+
*
|
|
24592
|
+
* @see https://www.w3.org/2000/xmlns/
|
|
24593
|
+
*/
|
|
24594
|
+
XMLNS: 'http://www.w3.org/2000/xmlns/',
|
|
24595
|
+
});
|
|
24596
|
+
|
|
24597
|
+
conventions$2.freeze = freeze;
|
|
24598
|
+
conventions$2.MIME_TYPE = MIME_TYPE;
|
|
24599
|
+
conventions$2.NAMESPACE = NAMESPACE$3;
|
|
24600
|
+
|
|
24601
|
+
var entities$1 = {};
|
|
24602
|
+
|
|
24603
|
+
(function (exports) {
|
|
24604
|
+
var freeze = conventions$2.freeze;
|
|
24605
|
+
|
|
24606
|
+
/**
|
|
24607
|
+
* The entities that are predefined in every XML document.
|
|
24608
|
+
*
|
|
24609
|
+
* @see https://www.w3.org/TR/2006/REC-xml11-20060816/#sec-predefined-ent W3C XML 1.1
|
|
24610
|
+
* @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-predefined-ent W3C XML 1.0
|
|
24611
|
+
* @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML Wikipedia
|
|
24612
|
+
*/
|
|
24613
|
+
exports.XML_ENTITIES = freeze({amp:'&', apos:"'", gt:'>', lt:'<', quot:'"'});
|
|
24614
|
+
|
|
24615
|
+
/**
|
|
24616
|
+
* A map of currently 241 entities that are detected in an HTML document.
|
|
24617
|
+
* They contain all entries from `XML_ENTITIES`.
|
|
24618
|
+
*
|
|
24619
|
+
* @see XML_ENTITIES
|
|
24620
|
+
* @see DOMParser.parseFromString
|
|
24621
|
+
* @see DOMImplementation.prototype.createHTMLDocument
|
|
24622
|
+
* @see https://html.spec.whatwg.org/#named-character-references WHATWG HTML(5) Spec
|
|
24623
|
+
* @see https://www.w3.org/TR/xml-entity-names/ W3C XML Entity Names
|
|
24624
|
+
* @see https://www.w3.org/TR/html4/sgml/entities.html W3C HTML4/SGML
|
|
24625
|
+
* @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML Wikipedia (HTML)
|
|
24626
|
+
* @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML Wikpedia (XHTML)
|
|
24627
|
+
*/
|
|
24628
|
+
exports.HTML_ENTITIES = freeze({
|
|
24367
24629
|
lt: '<',
|
|
24368
24630
|
gt: '>',
|
|
24369
24631
|
amp: '&',
|
|
@@ -24605,10 +24867,19 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
24605
24867
|
clubs: "♣",
|
|
24606
24868
|
hearts: "♥",
|
|
24607
24869
|
diams: "♦"
|
|
24608
|
-
};
|
|
24870
|
+
});
|
|
24871
|
+
|
|
24872
|
+
/**
|
|
24873
|
+
* @deprecated use `HTML_ENTITIES` instead
|
|
24874
|
+
* @see HTML_ENTITIES
|
|
24875
|
+
*/
|
|
24876
|
+
exports.entityMap = exports.HTML_ENTITIES;
|
|
24877
|
+
}(entities$1));
|
|
24609
24878
|
|
|
24610
24879
|
var sax$1 = {};
|
|
24611
24880
|
|
|
24881
|
+
var NAMESPACE$2 = conventions$2.NAMESPACE;
|
|
24882
|
+
|
|
24612
24883
|
//[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]
|
|
24613
24884
|
//[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
|
|
24614
24885
|
//[5] Name ::= NameStartChar (NameChar)*
|
|
@@ -24726,7 +24997,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
24726
24997
|
switch(source.charAt(tagStart+1)){
|
|
24727
24998
|
case '/':
|
|
24728
24999
|
var end = source.indexOf('>',tagStart+3);
|
|
24729
|
-
var tagName = source.substring(tagStart+2,end);
|
|
25000
|
+
var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, '');
|
|
24730
25001
|
var config = parseStack.pop();
|
|
24731
25002
|
if(end<0){
|
|
24732
25003
|
|
|
@@ -24799,12 +25070,10 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
24799
25070
|
parseStack.push(el);
|
|
24800
25071
|
}
|
|
24801
25072
|
}
|
|
24802
|
-
|
|
24803
|
-
|
|
24804
|
-
|
|
24805
|
-
if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){
|
|
25073
|
+
|
|
25074
|
+
if (NAMESPACE$2.isHTML(el.uri) && !el.closed) {
|
|
24806
25075
|
end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder);
|
|
24807
|
-
}else {
|
|
25076
|
+
} else {
|
|
24808
25077
|
end++;
|
|
24809
25078
|
}
|
|
24810
25079
|
}
|
|
@@ -24940,7 +25209,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
24940
25209
|
errorHandler.warning('attribute "'+value+'" missed quot(")!');
|
|
24941
25210
|
addAttribute(attrName, value.replace(/&#?\w+;/g,entityReplacer), start);
|
|
24942
25211
|
}else {
|
|
24943
|
-
if(currentNSMap['']
|
|
25212
|
+
if(!NAMESPACE$2.isHTML(currentNSMap['']) || !value.match(/^(?:disabled|checked|selected)$/i)){
|
|
24944
25213
|
errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!');
|
|
24945
25214
|
}
|
|
24946
25215
|
addAttribute(value, value, start);
|
|
@@ -24988,7 +25257,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
24988
25257
|
//case S_ATTR_NOQUOT_VALUE:void();break;
|
|
24989
25258
|
case S_ATTR_SPACE:
|
|
24990
25259
|
el.tagName;
|
|
24991
|
-
if(currentNSMap['']
|
|
25260
|
+
if (!NAMESPACE$2.isHTML(currentNSMap['']) || !attrName.match(/^(?:disabled|checked|selected)$/i)) {
|
|
24992
25261
|
errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead2!!');
|
|
24993
25262
|
}
|
|
24994
25263
|
addAttribute(attrName, attrName, start);
|
|
@@ -25047,7 +25316,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25047
25316
|
//console.log(currentNSMap,1)
|
|
25048
25317
|
}
|
|
25049
25318
|
currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
|
|
25050
|
-
a.uri =
|
|
25319
|
+
a.uri = NAMESPACE$2.XMLNS;
|
|
25051
25320
|
domBuilder.startPrefixMapping(nsPrefix, value);
|
|
25052
25321
|
}
|
|
25053
25322
|
}
|
|
@@ -25057,7 +25326,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25057
25326
|
var prefix = a.prefix;
|
|
25058
25327
|
if(prefix){//no prefix attribute has no namespace
|
|
25059
25328
|
if(prefix === 'xml'){
|
|
25060
|
-
a.uri =
|
|
25329
|
+
a.uri = NAMESPACE$2.XML;
|
|
25061
25330
|
}if(prefix !== 'xmlns'){
|
|
25062
25331
|
a.uri = currentNSMap[prefix || ''];
|
|
25063
25332
|
|
|
@@ -25254,11 +25523,74 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25254
25523
|
|
|
25255
25524
|
var dom = {};
|
|
25256
25525
|
|
|
25526
|
+
var conventions$1 = conventions$2;
|
|
25527
|
+
|
|
25528
|
+
var NAMESPACE$1 = conventions$1.NAMESPACE;
|
|
25529
|
+
|
|
25530
|
+
/**
|
|
25531
|
+
* A prerequisite for `[].filter`, to drop elements that are empty
|
|
25532
|
+
* @param {string} input
|
|
25533
|
+
* @returns {boolean}
|
|
25534
|
+
*/
|
|
25535
|
+
function notEmptyString (input) {
|
|
25536
|
+
return input !== ''
|
|
25537
|
+
}
|
|
25538
|
+
/**
|
|
25539
|
+
* @see https://infra.spec.whatwg.org/#split-on-ascii-whitespace
|
|
25540
|
+
* @see https://infra.spec.whatwg.org/#ascii-whitespace
|
|
25541
|
+
*
|
|
25542
|
+
* @param {string} input
|
|
25543
|
+
* @returns {string[]} (can be empty)
|
|
25544
|
+
*/
|
|
25545
|
+
function splitOnASCIIWhitespace(input) {
|
|
25546
|
+
// U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, U+0020 SPACE
|
|
25547
|
+
return input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : []
|
|
25548
|
+
}
|
|
25549
|
+
|
|
25550
|
+
/**
|
|
25551
|
+
* Adds element as a key to current if it is not already present.
|
|
25552
|
+
*
|
|
25553
|
+
* @param {Record<string, boolean | undefined>} current
|
|
25554
|
+
* @param {string} element
|
|
25555
|
+
* @returns {Record<string, boolean | undefined>}
|
|
25556
|
+
*/
|
|
25557
|
+
function orderedSetReducer (current, element) {
|
|
25558
|
+
if (!current.hasOwnProperty(element)) {
|
|
25559
|
+
current[element] = true;
|
|
25560
|
+
}
|
|
25561
|
+
return current;
|
|
25562
|
+
}
|
|
25563
|
+
|
|
25564
|
+
/**
|
|
25565
|
+
* @see https://infra.spec.whatwg.org/#ordered-set
|
|
25566
|
+
* @param {string} input
|
|
25567
|
+
* @returns {string[]}
|
|
25568
|
+
*/
|
|
25569
|
+
function toOrderedSet(input) {
|
|
25570
|
+
if (!input) return [];
|
|
25571
|
+
var list = splitOnASCIIWhitespace(input);
|
|
25572
|
+
return Object.keys(list.reduce(orderedSetReducer, {}))
|
|
25573
|
+
}
|
|
25574
|
+
|
|
25575
|
+
/**
|
|
25576
|
+
* Uses `list.indexOf` to implement something like `Array.prototype.includes`,
|
|
25577
|
+
* which we can not rely on being available.
|
|
25578
|
+
*
|
|
25579
|
+
* @param {any[]} list
|
|
25580
|
+
* @returns {function(any): boolean}
|
|
25581
|
+
*/
|
|
25582
|
+
function arrayIncludes (list) {
|
|
25583
|
+
return function(element) {
|
|
25584
|
+
return list && list.indexOf(element) !== -1;
|
|
25585
|
+
}
|
|
25586
|
+
}
|
|
25587
|
+
|
|
25257
25588
|
function copy(src,dest){
|
|
25258
25589
|
for(var p in src){
|
|
25259
25590
|
dest[p] = src[p];
|
|
25260
25591
|
}
|
|
25261
25592
|
}
|
|
25593
|
+
|
|
25262
25594
|
/**
|
|
25263
25595
|
^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));?
|
|
25264
25596
|
^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));?
|
|
@@ -25278,7 +25610,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25278
25610
|
pt.constructor = Class;
|
|
25279
25611
|
}
|
|
25280
25612
|
}
|
|
25281
|
-
|
|
25613
|
+
|
|
25282
25614
|
// Node Types
|
|
25283
25615
|
var NodeType = {};
|
|
25284
25616
|
var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
|
|
@@ -25334,6 +25666,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25334
25666
|
return error;
|
|
25335
25667
|
}DOMException.prototype = Error.prototype;
|
|
25336
25668
|
copy(ExceptionCode,DOMException);
|
|
25669
|
+
|
|
25337
25670
|
/**
|
|
25338
25671
|
* @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177
|
|
25339
25672
|
* 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.
|
|
@@ -25364,6 +25697,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25364
25697
|
return buf.join('');
|
|
25365
25698
|
}
|
|
25366
25699
|
};
|
|
25700
|
+
|
|
25367
25701
|
function LiveNodeList(node,refresh){
|
|
25368
25702
|
this._node = node;
|
|
25369
25703
|
this._refresh = refresh;
|
|
@@ -25385,9 +25719,15 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25385
25719
|
};
|
|
25386
25720
|
|
|
25387
25721
|
_extends(LiveNodeList,NodeList);
|
|
25722
|
+
|
|
25388
25723
|
/**
|
|
25389
|
-
*
|
|
25390
|
-
*
|
|
25724
|
+
* Objects implementing the NamedNodeMap interface are used
|
|
25725
|
+
* to represent collections of nodes that can be accessed by name.
|
|
25726
|
+
* Note that NamedNodeMap does not inherit from NodeList;
|
|
25727
|
+
* NamedNodeMaps are not maintained in any particular order.
|
|
25728
|
+
* Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index,
|
|
25729
|
+
* but this is simply to allow convenient enumeration of the contents of a NamedNodeMap,
|
|
25730
|
+
* and does not imply that the DOM specifies an order to these Nodes.
|
|
25391
25731
|
* NamedNodeMap objects in the DOM are live.
|
|
25392
25732
|
* used for attributes or DocumentType entities
|
|
25393
25733
|
*/
|
|
@@ -25498,54 +25838,108 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25498
25838
|
return null;
|
|
25499
25839
|
}
|
|
25500
25840
|
};
|
|
25841
|
+
|
|
25501
25842
|
/**
|
|
25502
|
-
*
|
|
25843
|
+
* The DOMImplementation interface represents an object providing methods
|
|
25844
|
+
* which are not dependent on any particular document.
|
|
25845
|
+
* Such an object is returned by the `Document.implementation` property.
|
|
25846
|
+
*
|
|
25847
|
+
* __The individual methods describe the differences compared to the specs.__
|
|
25848
|
+
*
|
|
25849
|
+
* @constructor
|
|
25850
|
+
*
|
|
25851
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN
|
|
25852
|
+
* @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core (Initial)
|
|
25853
|
+
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core
|
|
25854
|
+
* @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core
|
|
25855
|
+
* @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard
|
|
25503
25856
|
*/
|
|
25504
|
-
function DOMImplementation$1(
|
|
25505
|
-
this._features = {};
|
|
25506
|
-
if (features) {
|
|
25507
|
-
for (var feature in features) {
|
|
25508
|
-
this._features = features[feature];
|
|
25509
|
-
}
|
|
25510
|
-
}
|
|
25857
|
+
function DOMImplementation$1() {
|
|
25511
25858
|
}
|
|
25859
|
+
|
|
25512
25860
|
DOMImplementation$1.prototype = {
|
|
25513
|
-
|
|
25514
|
-
|
|
25515
|
-
|
|
25861
|
+
/**
|
|
25862
|
+
* The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given feature is supported.
|
|
25863
|
+
* The different implementations fairly diverged in what kind of features were reported.
|
|
25864
|
+
* The latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use.
|
|
25865
|
+
*
|
|
25866
|
+
* @deprecated It is deprecated and modern browsers return true in all cases.
|
|
25867
|
+
*
|
|
25868
|
+
* @param {string} feature
|
|
25869
|
+
* @param {string} [version]
|
|
25870
|
+
* @returns {boolean} always true
|
|
25871
|
+
*
|
|
25872
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN
|
|
25873
|
+
* @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core
|
|
25874
|
+
* @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard
|
|
25875
|
+
*/
|
|
25876
|
+
hasFeature: function(feature, version) {
|
|
25516
25877
|
return true;
|
|
25517
|
-
} else {
|
|
25518
|
-
return false;
|
|
25519
|
-
}
|
|
25520
25878
|
},
|
|
25521
|
-
|
|
25522
|
-
|
|
25879
|
+
/**
|
|
25880
|
+
* Creates an XML Document object of the specified type with its document element.
|
|
25881
|
+
*
|
|
25882
|
+
* __It behaves slightly different from the description in the living standard__:
|
|
25883
|
+
* - There is no interface/class `XMLDocument`, it returns a `Document` instance.
|
|
25884
|
+
* - `contentType`, `encoding`, `mode`, `origin`, `url` fields are currently not declared.
|
|
25885
|
+
* - this implementation is not validating names or qualified names
|
|
25886
|
+
* (when parsing XML strings, the SAX parser takes care of that)
|
|
25887
|
+
*
|
|
25888
|
+
* @param {string|null} namespaceURI
|
|
25889
|
+
* @param {string} qualifiedName
|
|
25890
|
+
* @param {DocumentType=null} doctype
|
|
25891
|
+
* @returns {Document}
|
|
25892
|
+
*
|
|
25893
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN
|
|
25894
|
+
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM Level 2 Core (initial)
|
|
25895
|
+
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core
|
|
25896
|
+
*
|
|
25897
|
+
* @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
|
|
25898
|
+
* @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
|
|
25899
|
+
* @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
|
|
25900
|
+
*/
|
|
25901
|
+
createDocument: function(namespaceURI, qualifiedName, doctype){
|
|
25523
25902
|
var doc = new Document();
|
|
25524
25903
|
doc.implementation = this;
|
|
25525
25904
|
doc.childNodes = new NodeList();
|
|
25526
|
-
doc.doctype = doctype;
|
|
25527
|
-
if(doctype){
|
|
25905
|
+
doc.doctype = doctype || null;
|
|
25906
|
+
if (doctype){
|
|
25528
25907
|
doc.appendChild(doctype);
|
|
25529
25908
|
}
|
|
25530
|
-
if(qualifiedName){
|
|
25531
|
-
var root = doc.createElementNS(namespaceURI,qualifiedName);
|
|
25909
|
+
if (qualifiedName){
|
|
25910
|
+
var root = doc.createElementNS(namespaceURI, qualifiedName);
|
|
25532
25911
|
doc.appendChild(root);
|
|
25533
25912
|
}
|
|
25534
25913
|
return doc;
|
|
25535
25914
|
},
|
|
25536
|
-
|
|
25537
|
-
|
|
25915
|
+
/**
|
|
25916
|
+
* Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.
|
|
25917
|
+
*
|
|
25918
|
+
* __This behavior is slightly different from the in the specs__:
|
|
25919
|
+
* - this implementation is not validating names or qualified names
|
|
25920
|
+
* (when parsing XML strings, the SAX parser takes care of that)
|
|
25921
|
+
*
|
|
25922
|
+
* @param {string} qualifiedName
|
|
25923
|
+
* @param {string} [publicId]
|
|
25924
|
+
* @param {string} [systemId]
|
|
25925
|
+
* @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation
|
|
25926
|
+
* or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`
|
|
25927
|
+
*
|
|
25928
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType MDN
|
|
25929
|
+
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM Level 2 Core
|
|
25930
|
+
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living Standard
|
|
25931
|
+
*
|
|
25932
|
+
* @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
|
|
25933
|
+
* @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
|
|
25934
|
+
* @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
|
|
25935
|
+
*/
|
|
25936
|
+
createDocumentType: function(qualifiedName, publicId, systemId){
|
|
25538
25937
|
var node = new DocumentType();
|
|
25539
25938
|
node.name = qualifiedName;
|
|
25540
25939
|
node.nodeName = qualifiedName;
|
|
25541
|
-
node.publicId = publicId;
|
|
25542
|
-
node.systemId = systemId;
|
|
25543
|
-
|
|
25544
|
-
//readonly attribute DOMString internalSubset;
|
|
25545
|
-
|
|
25546
|
-
//TODO:..
|
|
25547
|
-
// readonly attribute NamedNodeMap entities;
|
|
25548
|
-
// readonly attribute NamedNodeMap notations;
|
|
25940
|
+
node.publicId = publicId || '';
|
|
25941
|
+
node.systemId = systemId || '';
|
|
25942
|
+
|
|
25549
25943
|
return node;
|
|
25550
25944
|
}
|
|
25551
25945
|
};
|
|
@@ -25684,22 +26078,25 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25684
26078
|
|
|
25685
26079
|
function Document(){
|
|
25686
26080
|
}
|
|
26081
|
+
|
|
25687
26082
|
function _onAddAttribute(doc,el,newAttr){
|
|
25688
26083
|
doc && doc._inc++;
|
|
25689
26084
|
var ns = newAttr.namespaceURI ;
|
|
25690
|
-
if(ns
|
|
26085
|
+
if(ns === NAMESPACE$1.XMLNS){
|
|
25691
26086
|
//update namespace
|
|
25692
26087
|
el._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value;
|
|
25693
26088
|
}
|
|
25694
26089
|
}
|
|
26090
|
+
|
|
25695
26091
|
function _onRemoveAttribute(doc,el,newAttr,remove){
|
|
25696
26092
|
doc && doc._inc++;
|
|
25697
26093
|
var ns = newAttr.namespaceURI ;
|
|
25698
|
-
if(ns
|
|
26094
|
+
if(ns === NAMESPACE$1.XMLNS){
|
|
25699
26095
|
//update namespace
|
|
25700
26096
|
delete el._nsMap[newAttr.prefix?newAttr.localName:''];
|
|
25701
26097
|
}
|
|
25702
26098
|
}
|
|
26099
|
+
|
|
25703
26100
|
function _onUpdateChild(doc,el,newChild){
|
|
25704
26101
|
if(doc && doc._inc){
|
|
25705
26102
|
doc._inc++;
|
|
@@ -25815,8 +26212,8 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25815
26212
|
doctype : null,
|
|
25816
26213
|
documentElement : null,
|
|
25817
26214
|
_inc : 1,
|
|
25818
|
-
|
|
25819
|
-
insertBefore : function(newChild, refChild){//raises
|
|
26215
|
+
|
|
26216
|
+
insertBefore : function(newChild, refChild){//raises
|
|
25820
26217
|
if(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){
|
|
25821
26218
|
var child = newChild.firstChild;
|
|
25822
26219
|
while(child){
|
|
@@ -25829,7 +26226,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25829
26226
|
if(this.documentElement == null && newChild.nodeType == ELEMENT_NODE){
|
|
25830
26227
|
this.documentElement = newChild;
|
|
25831
26228
|
}
|
|
25832
|
-
|
|
26229
|
+
|
|
25833
26230
|
return _insertBefore(this,newChild,refChild),(newChild.ownerDocument = this),newChild;
|
|
25834
26231
|
},
|
|
25835
26232
|
removeChild : function(oldChild){
|
|
@@ -25855,28 +26252,58 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
25855
26252
|
});
|
|
25856
26253
|
return rtv;
|
|
25857
26254
|
},
|
|
25858
|
-
|
|
25859
|
-
|
|
25860
|
-
|
|
26255
|
+
|
|
26256
|
+
/**
|
|
26257
|
+
* The `getElementsByClassName` method of `Document` interface returns an array-like object
|
|
26258
|
+
* of all child elements which have **all** of the given class name(s).
|
|
26259
|
+
*
|
|
26260
|
+
* Returns an empty list if `classeNames` is an empty string or only contains HTML white space characters.
|
|
26261
|
+
*
|
|
26262
|
+
*
|
|
26263
|
+
* Warning: This is a live LiveNodeList.
|
|
26264
|
+
* Changes in the DOM will reflect in the array as the changes occur.
|
|
26265
|
+
* If an element selected by this array no longer qualifies for the selector,
|
|
26266
|
+
* it will automatically be removed. Be aware of this for iteration purposes.
|
|
26267
|
+
*
|
|
26268
|
+
* @param {string} classNames is a string representing the class name(s) to match; multiple class names are separated by (ASCII-)whitespace
|
|
26269
|
+
*
|
|
26270
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
|
|
26271
|
+
* @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
|
|
26272
|
+
*/
|
|
26273
|
+
getElementsByClassName: function(classNames) {
|
|
26274
|
+
var classNamesSet = toOrderedSet(classNames);
|
|
25861
26275
|
return new LiveNodeList(this, function(base) {
|
|
25862
26276
|
var ls = [];
|
|
25863
|
-
|
|
25864
|
-
|
|
25865
|
-
if(
|
|
25866
|
-
|
|
26277
|
+
if (classNamesSet.length > 0) {
|
|
26278
|
+
_visitNode(base.documentElement, function(node) {
|
|
26279
|
+
if(node !== base && node.nodeType === ELEMENT_NODE) {
|
|
26280
|
+
var nodeClassNames = node.getAttribute('class');
|
|
26281
|
+
// can be null if the attribute does not exist
|
|
26282
|
+
if (nodeClassNames) {
|
|
26283
|
+
// before splitting and iterating just compare them for the most common case
|
|
26284
|
+
var matches = classNames === nodeClassNames;
|
|
26285
|
+
if (!matches) {
|
|
26286
|
+
var nodeClassNamesSet = toOrderedSet(nodeClassNames);
|
|
26287
|
+
matches = classNamesSet.every(arrayIncludes(nodeClassNamesSet));
|
|
26288
|
+
}
|
|
26289
|
+
if(matches) {
|
|
26290
|
+
ls.push(node);
|
|
26291
|
+
}
|
|
26292
|
+
}
|
|
25867
26293
|
}
|
|
25868
|
-
}
|
|
25869
|
-
}
|
|
26294
|
+
});
|
|
26295
|
+
}
|
|
25870
26296
|
return ls;
|
|
25871
26297
|
});
|
|
25872
26298
|
},
|
|
25873
|
-
|
|
26299
|
+
|
|
25874
26300
|
//document factory method:
|
|
25875
26301
|
createElement : function(tagName){
|
|
25876
26302
|
var node = new Element();
|
|
25877
26303
|
node.ownerDocument = this;
|
|
25878
26304
|
node.nodeName = tagName;
|
|
25879
26305
|
node.tagName = tagName;
|
|
26306
|
+
node.localName = tagName;
|
|
25880
26307
|
node.childNodes = new NodeList();
|
|
25881
26308
|
var attrs = node.attributes = new NamedNodeMap();
|
|
25882
26309
|
attrs._ownerElement = node;
|
|
@@ -26183,36 +26610,49 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26183
26610
|
//console.log('###',this.nodeType,uri,prefix,buf.join(''))
|
|
26184
26611
|
return buf.join('');
|
|
26185
26612
|
}
|
|
26186
|
-
|
|
26187
|
-
|
|
26613
|
+
|
|
26614
|
+
function needNamespaceDefine(node, isHTML, visibleNamespaces) {
|
|
26615
|
+
var prefix = node.prefix || '';
|
|
26188
26616
|
var uri = node.namespaceURI;
|
|
26189
|
-
|
|
26617
|
+
// According to [Namespaces in XML 1.0](https://www.w3.org/TR/REC-xml-names/#ns-using) ,
|
|
26618
|
+
// and more specifically https://www.w3.org/TR/REC-xml-names/#nsc-NoPrefixUndecl :
|
|
26619
|
+
// > In a namespace declaration for a prefix [...], the attribute value MUST NOT be empty.
|
|
26620
|
+
// in a similar manner [Namespaces in XML 1.1](https://www.w3.org/TR/xml-names11/#ns-using)
|
|
26621
|
+
// and more specifically https://www.w3.org/TR/xml-names11/#nsc-NSDeclared :
|
|
26622
|
+
// > [...] Furthermore, the attribute value [...] must not be an empty string.
|
|
26623
|
+
// so serializing empty namespace value like xmlns:ds="" would produce an invalid XML document.
|
|
26624
|
+
if (!uri) {
|
|
26190
26625
|
return false;
|
|
26191
26626
|
}
|
|
26192
|
-
if (prefix === "xml" && uri ===
|
|
26193
|
-
|| uri == 'http://www.w3.org/2000/xmlns/'){
|
|
26627
|
+
if (prefix === "xml" && uri === NAMESPACE$1.XML || uri === NAMESPACE$1.XMLNS) {
|
|
26194
26628
|
return false;
|
|
26195
26629
|
}
|
|
26196
26630
|
|
|
26197
26631
|
var i = visibleNamespaces.length;
|
|
26198
|
-
//console.log('@@@@',node.tagName,prefix,uri,visibleNamespaces)
|
|
26199
26632
|
while (i--) {
|
|
26200
26633
|
var ns = visibleNamespaces[i];
|
|
26201
26634
|
// get namespace prefix
|
|
26202
|
-
|
|
26203
|
-
|
|
26204
|
-
return ns.namespace != uri;
|
|
26635
|
+
if (ns.prefix === prefix) {
|
|
26636
|
+
return ns.namespace !== uri;
|
|
26205
26637
|
}
|
|
26206
26638
|
}
|
|
26207
|
-
//console.log(isHTML,uri,prefix=='')
|
|
26208
|
-
//if(isHTML && prefix ==null && uri == 'http://www.w3.org/1999/xhtml'){
|
|
26209
|
-
// return false;
|
|
26210
|
-
//}
|
|
26211
|
-
//node.flag = '11111'
|
|
26212
|
-
//console.error(3,true,node.flag,node.prefix,node.namespaceURI)
|
|
26213
26639
|
return true;
|
|
26214
26640
|
}
|
|
26641
|
+
/**
|
|
26642
|
+
* Well-formed constraint: No < in Attribute Values
|
|
26643
|
+
* The replacement text of any entity referred to directly or indirectly in an attribute value must not contain a <.
|
|
26644
|
+
* @see https://www.w3.org/TR/xml/#CleanAttrVals
|
|
26645
|
+
* @see https://www.w3.org/TR/xml/#NT-AttValue
|
|
26646
|
+
*/
|
|
26647
|
+
function addSerializedAttribute(buf, qualifiedName, value) {
|
|
26648
|
+
buf.push(' ', qualifiedName, '="', value.replace(/[<&"]/g,_xmlEncoder), '"');
|
|
26649
|
+
}
|
|
26650
|
+
|
|
26215
26651
|
function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
|
|
26652
|
+
if (!visibleNamespaces) {
|
|
26653
|
+
visibleNamespaces = [];
|
|
26654
|
+
}
|
|
26655
|
+
|
|
26216
26656
|
if(nodeFilter){
|
|
26217
26657
|
node = nodeFilter(node);
|
|
26218
26658
|
if(node){
|
|
@@ -26225,20 +26665,40 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26225
26665
|
}
|
|
26226
26666
|
//buf.sort.apply(attrs, attributeSorter);
|
|
26227
26667
|
}
|
|
26668
|
+
|
|
26228
26669
|
switch(node.nodeType){
|
|
26229
26670
|
case ELEMENT_NODE:
|
|
26230
|
-
if (!visibleNamespaces) visibleNamespaces = [];
|
|
26231
|
-
visibleNamespaces.length;
|
|
26232
26671
|
var attrs = node.attributes;
|
|
26233
26672
|
var len = attrs.length;
|
|
26234
26673
|
var child = node.firstChild;
|
|
26235
26674
|
var nodeName = node.tagName;
|
|
26236
26675
|
|
|
26237
|
-
isHTML =
|
|
26238
|
-
|
|
26239
|
-
|
|
26240
|
-
|
|
26241
|
-
|
|
26676
|
+
isHTML = NAMESPACE$1.isHTML(node.namespaceURI) || isHTML;
|
|
26677
|
+
|
|
26678
|
+
var prefixedNodeName = nodeName;
|
|
26679
|
+
if (!isHTML && !node.prefix && node.namespaceURI) {
|
|
26680
|
+
var defaultNS;
|
|
26681
|
+
for (var ai = 0; ai < attrs.length; ai++) {
|
|
26682
|
+
if (attrs.item(ai).name === 'xmlns') {
|
|
26683
|
+
defaultNS = attrs.item(ai).value;
|
|
26684
|
+
break
|
|
26685
|
+
}
|
|
26686
|
+
}
|
|
26687
|
+
if (defaultNS !== node.namespaceURI) {
|
|
26688
|
+
for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
|
|
26689
|
+
var namespace = visibleNamespaces[nsi];
|
|
26690
|
+
if (namespace.namespace === node.namespaceURI) {
|
|
26691
|
+
if (namespace.prefix) {
|
|
26692
|
+
prefixedNodeName = namespace.prefix + ':' + nodeName;
|
|
26693
|
+
}
|
|
26694
|
+
break
|
|
26695
|
+
}
|
|
26696
|
+
}
|
|
26697
|
+
}
|
|
26698
|
+
}
|
|
26699
|
+
|
|
26700
|
+
buf.push('<', prefixedNodeName);
|
|
26701
|
+
|
|
26242
26702
|
for(var i=0;i<len;i++){
|
|
26243
26703
|
// add namespaces for attributes
|
|
26244
26704
|
var attr = attrs.item(i);
|
|
@@ -26248,28 +26708,24 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26248
26708
|
visibleNamespaces.push({ prefix: '', namespace: attr.value });
|
|
26249
26709
|
}
|
|
26250
26710
|
}
|
|
26711
|
+
|
|
26251
26712
|
for(var i=0;i<len;i++){
|
|
26252
26713
|
var attr = attrs.item(i);
|
|
26253
26714
|
if (needNamespaceDefine(attr,isHTML, visibleNamespaces)) {
|
|
26254
26715
|
var prefix = attr.prefix||'';
|
|
26255
26716
|
var uri = attr.namespaceURI;
|
|
26256
|
-
|
|
26257
|
-
buf.push(ns, '="' , uri , '"');
|
|
26717
|
+
addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : "xmlns", uri);
|
|
26258
26718
|
visibleNamespaces.push({ prefix: prefix, namespace:uri });
|
|
26259
26719
|
}
|
|
26260
26720
|
serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
|
|
26261
26721
|
}
|
|
26722
|
+
|
|
26262
26723
|
// add namespace for current node
|
|
26263
|
-
if (needNamespaceDefine(node,isHTML, visibleNamespaces)) {
|
|
26724
|
+
if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {
|
|
26264
26725
|
var prefix = node.prefix||'';
|
|
26265
26726
|
var uri = node.namespaceURI;
|
|
26266
|
-
|
|
26267
|
-
|
|
26268
|
-
// Empty namespace URL will we produce an invalid XML document
|
|
26269
|
-
var ns = prefix ? ' xmlns:' + prefix : " xmlns";
|
|
26270
|
-
buf.push(ns, '="' , uri , '"');
|
|
26271
|
-
visibleNamespaces.push({ prefix: prefix, namespace:uri });
|
|
26272
|
-
}
|
|
26727
|
+
addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : "xmlns", uri);
|
|
26728
|
+
visibleNamespaces.push({ prefix: prefix, namespace:uri });
|
|
26273
26729
|
}
|
|
26274
26730
|
|
|
26275
26731
|
if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
|
|
@@ -26280,18 +26736,18 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26280
26736
|
if(child.data){
|
|
26281
26737
|
buf.push(child.data);
|
|
26282
26738
|
}else {
|
|
26283
|
-
serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
|
|
26739
|
+
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
|
|
26284
26740
|
}
|
|
26285
26741
|
child = child.nextSibling;
|
|
26286
26742
|
}
|
|
26287
26743
|
}else
|
|
26288
26744
|
{
|
|
26289
26745
|
while(child){
|
|
26290
|
-
serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
|
|
26746
|
+
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
|
|
26291
26747
|
child = child.nextSibling;
|
|
26292
26748
|
}
|
|
26293
26749
|
}
|
|
26294
|
-
buf.push('</',
|
|
26750
|
+
buf.push('</',prefixedNodeName,'>');
|
|
26295
26751
|
}else {
|
|
26296
26752
|
buf.push('/>');
|
|
26297
26753
|
}
|
|
@@ -26302,18 +26758,12 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26302
26758
|
case DOCUMENT_FRAGMENT_NODE:
|
|
26303
26759
|
var child = node.firstChild;
|
|
26304
26760
|
while(child){
|
|
26305
|
-
serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
|
|
26761
|
+
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
|
|
26306
26762
|
child = child.nextSibling;
|
|
26307
26763
|
}
|
|
26308
26764
|
return;
|
|
26309
26765
|
case ATTRIBUTE_NODE:
|
|
26310
|
-
|
|
26311
|
-
* Well-formedness constraint: No < in Attribute Values
|
|
26312
|
-
* The replacement text of any entity referred to directly or indirectly in an attribute value must not contain a <.
|
|
26313
|
-
* @see https://www.w3.org/TR/xml/#CleanAttrVals
|
|
26314
|
-
* @see https://www.w3.org/TR/xml/#NT-AttValue
|
|
26315
|
-
*/
|
|
26316
|
-
return buf.push(' ', node.name, '="', node.value.replace(/[<&"]/g,_xmlEncoder), '"');
|
|
26766
|
+
return addSerializedAttribute(buf, node.name, node.value);
|
|
26317
26767
|
case TEXT_NODE:
|
|
26318
26768
|
/**
|
|
26319
26769
|
* The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
|
|
@@ -26464,10 +26914,12 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26464
26914
|
return this.$$length;
|
|
26465
26915
|
}
|
|
26466
26916
|
});
|
|
26917
|
+
|
|
26467
26918
|
Object.defineProperty(Node.prototype,'textContent',{
|
|
26468
26919
|
get:function(){
|
|
26469
26920
|
return getTextContent(this);
|
|
26470
26921
|
},
|
|
26922
|
+
|
|
26471
26923
|
set:function(data){
|
|
26472
26924
|
switch(this.nodeType){
|
|
26473
26925
|
case ELEMENT_NODE:
|
|
@@ -26479,8 +26931,8 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26479
26931
|
this.appendChild(this.ownerDocument.createTextNode(data));
|
|
26480
26932
|
}
|
|
26481
26933
|
break;
|
|
26934
|
+
|
|
26482
26935
|
default:
|
|
26483
|
-
//TODO:
|
|
26484
26936
|
this.data = data;
|
|
26485
26937
|
this.value = data;
|
|
26486
26938
|
this.nodeValue = data;
|
|
@@ -26505,6 +26957,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26505
26957
|
return node.nodeValue;
|
|
26506
26958
|
}
|
|
26507
26959
|
}
|
|
26960
|
+
|
|
26508
26961
|
__set__ = function(object,key,value){
|
|
26509
26962
|
//console.log(value)
|
|
26510
26963
|
object['$$'+key] = value;
|
|
@@ -26514,11 +26967,19 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26514
26967
|
}
|
|
26515
26968
|
|
|
26516
26969
|
//if(typeof require == 'function'){
|
|
26517
|
-
dom.
|
|
26970
|
+
dom.DocumentType = DocumentType;
|
|
26518
26971
|
dom.DOMException = DOMException;
|
|
26519
26972
|
dom.DOMImplementation = DOMImplementation$1;
|
|
26973
|
+
dom.Element = Element;
|
|
26974
|
+
dom.Node = Node;
|
|
26975
|
+
dom.NodeList = NodeList;
|
|
26520
26976
|
dom.XMLSerializer = XMLSerializer;
|
|
26521
26977
|
|
|
26978
|
+
var conventions = conventions$2;
|
|
26979
|
+
var entities = entities$1;
|
|
26980
|
+
|
|
26981
|
+
var NAMESPACE = conventions.NAMESPACE;
|
|
26982
|
+
|
|
26522
26983
|
function DOMParser(options){
|
|
26523
26984
|
this.options = options ||{locator:{}};
|
|
26524
26985
|
}
|
|
@@ -26531,7 +26992,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26531
26992
|
var locator = options.locator;
|
|
26532
26993
|
var defaultNSMap = options.xmlns||{};
|
|
26533
26994
|
var isHTML = /\/x?html?$/.test(mimeType);//mimeType.toLowerCase().indexOf('html') > -1;
|
|
26534
|
-
var entityMap = isHTML?
|
|
26995
|
+
var entityMap = isHTML ? entities.HTML_ENTITIES : entities.XML_ENTITIES;
|
|
26535
26996
|
if(locator){
|
|
26536
26997
|
domBuilder.setDocumentLocator(locator);
|
|
26537
26998
|
}
|
|
@@ -26539,9 +27000,9 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26539
27000
|
sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator);
|
|
26540
27001
|
sax.domBuilder = options.domBuilder || domBuilder;
|
|
26541
27002
|
if(isHTML){
|
|
26542
|
-
defaultNSMap['']=
|
|
27003
|
+
defaultNSMap[''] = NAMESPACE.HTML;
|
|
26543
27004
|
}
|
|
26544
|
-
defaultNSMap.xml = defaultNSMap.xml ||
|
|
27005
|
+
defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;
|
|
26545
27006
|
if(source && typeof source === 'string'){
|
|
26546
27007
|
sax.parse(source,defaultNSMap,entityMap);
|
|
26547
27008
|
}else {
|
|
@@ -26763,7 +27224,6 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
26763
27224
|
}//appendChild and setAttributeNS are preformance key
|
|
26764
27225
|
|
|
26765
27226
|
//if(typeof require == 'function'){
|
|
26766
|
-
var htmlEntity = entities;
|
|
26767
27227
|
var sax = sax$1;
|
|
26768
27228
|
var XMLReader = sax.XMLReader;
|
|
26769
27229
|
var ParseError = sax.ParseError;
|
|
@@ -27232,7 +27692,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
27232
27692
|
debug('received original response', _this.status, _this.statusText);
|
|
27233
27693
|
debug('original response body:', _this.response);
|
|
27234
27694
|
var responseHeaders = originalRequest_1.getAllResponseHeaders();
|
|
27235
|
-
debug('original response headers', responseHeaders);
|
|
27695
|
+
debug('original response headers:\n', responseHeaders);
|
|
27236
27696
|
_this._responseHeaders = headers_utils_1.stringToHeaders(responseHeaders);
|
|
27237
27697
|
debug('original response headers (normalized)', _this._responseHeaders);
|
|
27238
27698
|
debug('original response finished');
|
|
@@ -27510,6 +27970,23 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
27510
27970
|
};
|
|
27511
27971
|
}
|
|
27512
27972
|
|
|
27973
|
+
/**
|
|
27974
|
+
* Pipes all emitted events from one emitter to another.
|
|
27975
|
+
*/
|
|
27976
|
+
function pipeEvents(source, destination) {
|
|
27977
|
+
const rawEmit = source.emit;
|
|
27978
|
+
// @ts-ignore
|
|
27979
|
+
if (rawEmit._isPiped) {
|
|
27980
|
+
return;
|
|
27981
|
+
}
|
|
27982
|
+
source.emit = function (event, ...data) {
|
|
27983
|
+
destination.emit(event, ...data);
|
|
27984
|
+
return rawEmit.call(this, event, ...data);
|
|
27985
|
+
};
|
|
27986
|
+
// @ts-ignore
|
|
27987
|
+
source.emit._isPiped = true;
|
|
27988
|
+
}
|
|
27989
|
+
|
|
27513
27990
|
// Declare the list of event handlers on the module's scope
|
|
27514
27991
|
// so it persists between Fash refreshes of the application's code.
|
|
27515
27992
|
let listeners = [];
|
|
@@ -27528,12 +28005,15 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
27528
28005
|
if (lib$5.exports.isNodeProcess()) {
|
|
27529
28006
|
throw new Error(devUtils.formatMessage('Failed to execute `setupWorker` in a non-browser environment. Consider using `setupServer` for Node.js environment instead.'));
|
|
27530
28007
|
}
|
|
28008
|
+
const emitter = new lib$4.StrictEventEmitter();
|
|
28009
|
+
const publicEmitter = new lib$4.StrictEventEmitter();
|
|
28010
|
+
pipeEvents(emitter, publicEmitter);
|
|
27531
28011
|
const context = {
|
|
27532
28012
|
startOptions: undefined,
|
|
27533
28013
|
worker: null,
|
|
27534
28014
|
registration: null,
|
|
27535
28015
|
requestHandlers: [...requestHandlers],
|
|
27536
|
-
emitter
|
|
28016
|
+
emitter,
|
|
27537
28017
|
workerChannel: {
|
|
27538
28018
|
on(eventType, callback) {
|
|
27539
28019
|
context.events.addListener(navigator.serviceWorker, 'message', (event) => {
|
|
@@ -27599,7 +28079,12 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
27599
28079
|
: createStop(context);
|
|
27600
28080
|
return {
|
|
27601
28081
|
start: prepareStartHandler(startHandler, context),
|
|
27602
|
-
stop
|
|
28082
|
+
stop() {
|
|
28083
|
+
context.events.removeAllListeners();
|
|
28084
|
+
context.emitter.removeAllListeners();
|
|
28085
|
+
publicEmitter.removeAllListeners();
|
|
28086
|
+
stopHandler();
|
|
28087
|
+
},
|
|
27603
28088
|
use(...handlers) {
|
|
27604
28089
|
use(context.requestHandlers, ...handlers);
|
|
27605
28090
|
},
|
|
@@ -27626,8 +28111,16 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
27626
28111
|
console.groupEnd();
|
|
27627
28112
|
});
|
|
27628
28113
|
},
|
|
27629
|
-
|
|
27630
|
-
|
|
28114
|
+
events: {
|
|
28115
|
+
on(...args) {
|
|
28116
|
+
return publicEmitter.on(...args);
|
|
28117
|
+
},
|
|
28118
|
+
removeListener(...args) {
|
|
28119
|
+
return publicEmitter.removeListener(...args);
|
|
28120
|
+
},
|
|
28121
|
+
removeAllListeners(...args) {
|
|
28122
|
+
return publicEmitter.removeAllListeners(...args);
|
|
28123
|
+
},
|
|
27631
28124
|
},
|
|
27632
28125
|
};
|
|
27633
28126
|
}
|