update node modules
This commit is contained in:
9
node_modules/w3c-xmlserializer/lib/XMLSerializer-impl.js
generated
vendored
9
node_modules/w3c-xmlserializer/lib/XMLSerializer-impl.js
generated
vendored
@@ -1,9 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
const { produceXMLSerialization } = require("./serialization");
|
||||
|
||||
exports.implementation = class XMLSerializerImpl {
|
||||
serializeToString(root) {
|
||||
return produceXMLSerialization(root, false);
|
||||
}
|
||||
};
|
113
node_modules/w3c-xmlserializer/lib/XMLSerializer.js
generated
vendored
113
node_modules/w3c-xmlserializer/lib/XMLSerializer.js
generated
vendored
@@ -1,113 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const impl = utils.implSymbol;
|
||||
|
||||
class XMLSerializer {
|
||||
constructor() {
|
||||
return iface.setup(Object.create(new.target.prototype));
|
||||
}
|
||||
|
||||
serializeToString(root) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'serializeToString' on 'XMLSerializer': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = utils.tryImplForWrapper(curArg);
|
||||
args.push(curArg);
|
||||
}
|
||||
return this[impl].serializeToString(...args);
|
||||
}
|
||||
}
|
||||
Object.defineProperties(XMLSerializer.prototype, {
|
||||
serializeToString: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "XMLSerializer", configurable: true }
|
||||
});
|
||||
const iface = {
|
||||
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
|
||||
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
|
||||
// implementing this mixin interface.
|
||||
_mixedIntoPredicates: [],
|
||||
is(obj) {
|
||||
if (obj) {
|
||||
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isImpl(obj) {
|
||||
if (obj) {
|
||||
if (obj instanceof Impl.implementation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const wrapper = utils.wrapperForImpl(obj);
|
||||
for (const isMixedInto of module.exports._mixedIntoPredicates) {
|
||||
if (isMixedInto(wrapper)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
convert(obj, { context = "The provided value" } = {}) {
|
||||
if (module.exports.is(obj)) {
|
||||
return utils.implForWrapper(obj);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'XMLSerializer'.`);
|
||||
},
|
||||
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(XMLSerializer.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
createImpl(constructorArgs, privateData) {
|
||||
let obj = Object.create(XMLSerializer.prototype);
|
||||
obj = this.setup(obj, constructorArgs, privateData);
|
||||
return utils.implForWrapper(obj);
|
||||
},
|
||||
_internalSetup(obj) {},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
|
||||
privateData.wrapper = obj;
|
||||
|
||||
this._internalSetup(obj);
|
||||
Object.defineProperty(obj, impl, {
|
||||
value: new Impl.implementation(constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
if (Impl.init) {
|
||||
Impl.init(obj[impl], privateData);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
interface: XMLSerializer,
|
||||
expose: {
|
||||
Window: { XMLSerializer }
|
||||
}
|
||||
}; // iface
|
||||
module.exports = iface;
|
||||
|
||||
const Impl = require("./XMLSerializer-impl.js");
|
9
node_modules/w3c-xmlserializer/lib/index.js
generated
vendored
9
node_modules/w3c-xmlserializer/lib/index.js
generated
vendored
@@ -1,9 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
const { produceXMLSerialization } = require("./serialization");
|
||||
const XMLSerializer = require("./XMLSerializer");
|
||||
|
||||
module.exports = {
|
||||
XMLSerializer,
|
||||
produceXMLSerialization
|
||||
};
|
@@ -1,6 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
const DOMException = require("domexception");
|
||||
const xnv = require("xml-name-validator");
|
||||
|
||||
const attributeUtils = require("./attributes");
|
||||
@@ -61,7 +60,7 @@ function recordNamespaceInformation(element, map, prefixMap) {
|
||||
|
||||
function serializeDocumentType(node, namespace, prefixMap, requireWellFormed) {
|
||||
if (requireWellFormed && !PUBID_CHAR.test(node.publicId)) {
|
||||
throw new Error("Node publicId is not well formed");
|
||||
throw new Error("Failed to serialize XML: document type node publicId is not well-formed.");
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -69,7 +68,7 @@ function serializeDocumentType(node, namespace, prefixMap, requireWellFormed) {
|
||||
(!XML_CHAR.test(node.systemId) ||
|
||||
(node.systemId.includes('"') && node.systemId.includes("'")))
|
||||
) {
|
||||
throw new Error("Node systemId is not well formed");
|
||||
throw new Error("Failed to serialize XML: document type node systemId is not well-formed.");
|
||||
}
|
||||
|
||||
let markup = `<!DOCTYPE ${node.name}`;
|
||||
@@ -94,13 +93,13 @@ function serializeProcessingInstruction(
|
||||
requireWellFormed &&
|
||||
(node.target.includes(":") || asciiCaseInsensitiveMatch(node.target, "xml"))
|
||||
) {
|
||||
throw new Error("Node target is not well formed");
|
||||
throw new Error("Failed to serialize XML: processing instruction node target is not well-formed.");
|
||||
}
|
||||
if (
|
||||
requireWellFormed &&
|
||||
(!XML_CHAR.test(node.data) || node.data.includes("?>"))
|
||||
) {
|
||||
throw new Error("Node data is not well formed");
|
||||
throw new Error("Failed to serialize XML: processing instruction node data is not well-formed.");
|
||||
}
|
||||
return `<?${node.target} ${node.data}?>`;
|
||||
}
|
||||
@@ -113,7 +112,7 @@ function serializeDocument(
|
||||
refs
|
||||
) {
|
||||
if (requireWellFormed && node.documentElement === null) {
|
||||
throw new Error("Document does not have a document element");
|
||||
throw new Error("Failed to serialize XML: document does not have a document element.");
|
||||
}
|
||||
let serializedDocument = "";
|
||||
for (const child of node.childNodes) {
|
||||
@@ -150,7 +149,7 @@ function serializeDocumentFragment(
|
||||
|
||||
function serializeText(node, namespace, prefixMap, requireWellFormed) {
|
||||
if (requireWellFormed && !XML_CHAR.test(node.data)) {
|
||||
throw new Error("Node data is not well formed");
|
||||
throw new Error("Failed to serialize XML: text node data is not well-formed.");
|
||||
}
|
||||
|
||||
return node.data
|
||||
@@ -161,14 +160,14 @@ function serializeText(node, namespace, prefixMap, requireWellFormed) {
|
||||
|
||||
function serializeComment(node, namespace, prefixMap, requireWellFormed) {
|
||||
if (requireWellFormed && !XML_CHAR.test(node.data)) {
|
||||
throw new Error("Node data is not well formed");
|
||||
throw new Error("Failed to serialize XML: comment node data is not well-formed.");
|
||||
}
|
||||
|
||||
if (
|
||||
requireWellFormed &&
|
||||
(node.data.includes("--") || node.data.endsWith("-"))
|
||||
) {
|
||||
throw new Error("Found hyphens in illegal places");
|
||||
throw new Error("Failed to serialize XML: found hyphens in illegal places in comment node data.");
|
||||
}
|
||||
return `<!--${node.data}-->`;
|
||||
}
|
||||
@@ -178,7 +177,7 @@ function serializeElement(node, namespace, prefixMap, requireWellFormed, refs) {
|
||||
requireWellFormed &&
|
||||
(node.localName.includes(":") || !xnv.name(node.localName))
|
||||
) {
|
||||
throw new Error("localName is not a valid XML name");
|
||||
throw new Error("Failed to serialize XML: element node localName is not a valid XML name.");
|
||||
}
|
||||
let markup = "<";
|
||||
let qualifiedName = "";
|
||||
@@ -208,7 +207,7 @@ function serializeElement(node, namespace, prefixMap, requireWellFormed, refs) {
|
||||
let candidatePrefix = attributeUtils.preferredPrefixString(map, ns, prefix);
|
||||
if (prefix === "xmlns") {
|
||||
if (requireWellFormed) {
|
||||
throw new Error("Elements can't have xmlns prefix");
|
||||
throw new Error("Failed to serialize XML: element nodes can't have a prefix of \"xmlns\".");
|
||||
}
|
||||
candidatePrefix = "xmlns";
|
||||
}
|
||||
@@ -359,21 +358,14 @@ function xmlSerialization(node, namespace, prefixMap, requireWellFormed, refs) {
|
||||
case NODE_TYPES.CDATA_SECTION_NODE:
|
||||
return serializeCDATASection(node);
|
||||
default:
|
||||
throw new TypeError("Only Nodes and Attr objects can be serialized");
|
||||
throw new TypeError("Failed to serialize XML: only Nodes can be serialized.");
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.produceXMLSerialization = (root, requireWellFormed) => {
|
||||
module.exports = (root, { requireWellFormed = false } = {}) => {
|
||||
const namespacePrefixMap = Object.create(null);
|
||||
namespacePrefixMap["http://www.w3.org/XML/1998/namespace"] = ["xml"];
|
||||
try {
|
||||
return xmlSerialization(root, null, namespacePrefixMap, requireWellFormed, {
|
||||
prefixIndex: 1
|
||||
});
|
||||
} catch (e) {
|
||||
throw new DOMException(
|
||||
"Failed to serialize XML: " + e.message,
|
||||
"InvalidStateError"
|
||||
);
|
||||
}
|
||||
return xmlSerialization(root, null, namespacePrefixMap, requireWellFormed, {
|
||||
prefixIndex: 1
|
||||
});
|
||||
};
|
127
node_modules/w3c-xmlserializer/lib/utils.js
generated
vendored
127
node_modules/w3c-xmlserializer/lib/utils.js
generated
vendored
@@ -1,127 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
// Returns "Type(value) is Object" in ES terminology.
|
||||
function isObject(value) {
|
||||
return typeof value === "object" && value !== null || typeof value === "function";
|
||||
}
|
||||
|
||||
function hasOwn(obj, prop) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, prop);
|
||||
}
|
||||
|
||||
const getOwnPropertyDescriptors = typeof Object.getOwnPropertyDescriptors === "function" ?
|
||||
Object.getOwnPropertyDescriptors :
|
||||
// Polyfill exists until we require Node.js v8.x
|
||||
// https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptors
|
||||
obj => {
|
||||
if (obj === undefined || obj === null) {
|
||||
throw new TypeError("Cannot convert undefined or null to object");
|
||||
}
|
||||
obj = Object(obj);
|
||||
const ownKeys = Reflect.ownKeys(obj);
|
||||
const descriptors = {};
|
||||
for (const key of ownKeys) {
|
||||
const descriptor = Reflect.getOwnPropertyDescriptor(obj, key);
|
||||
if (descriptor !== undefined) {
|
||||
Reflect.defineProperty(descriptors, key, {
|
||||
value: descriptor,
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
return descriptors;
|
||||
};
|
||||
|
||||
const wrapperSymbol = Symbol("wrapper");
|
||||
const implSymbol = Symbol("impl");
|
||||
const sameObjectCaches = Symbol("SameObject caches");
|
||||
|
||||
function getSameObject(wrapper, prop, creator) {
|
||||
if (!wrapper[sameObjectCaches]) {
|
||||
wrapper[sameObjectCaches] = Object.create(null);
|
||||
}
|
||||
|
||||
if (prop in wrapper[sameObjectCaches]) {
|
||||
return wrapper[sameObjectCaches][prop];
|
||||
}
|
||||
|
||||
wrapper[sameObjectCaches][prop] = creator();
|
||||
return wrapper[sameObjectCaches][prop];
|
||||
}
|
||||
|
||||
function wrapperForImpl(impl) {
|
||||
return impl ? impl[wrapperSymbol] : null;
|
||||
}
|
||||
|
||||
function implForWrapper(wrapper) {
|
||||
return wrapper ? wrapper[implSymbol] : null;
|
||||
}
|
||||
|
||||
function tryWrapperForImpl(impl) {
|
||||
const wrapper = wrapperForImpl(impl);
|
||||
return wrapper ? wrapper : impl;
|
||||
}
|
||||
|
||||
function tryImplForWrapper(wrapper) {
|
||||
const impl = implForWrapper(wrapper);
|
||||
return impl ? impl : wrapper;
|
||||
}
|
||||
|
||||
const iterInternalSymbol = Symbol("internal");
|
||||
const IteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()));
|
||||
|
||||
function isArrayIndexPropName(P) {
|
||||
if (typeof P !== "string") {
|
||||
return false;
|
||||
}
|
||||
const i = P >>> 0;
|
||||
if (i === Math.pow(2, 32) - 1) {
|
||||
return false;
|
||||
}
|
||||
const s = `${i}`;
|
||||
if (P !== s) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const supportsPropertyIndex = Symbol("supports property index");
|
||||
const supportedPropertyIndices = Symbol("supported property indices");
|
||||
const supportsPropertyName = Symbol("supports property name");
|
||||
const supportedPropertyNames = Symbol("supported property names");
|
||||
const indexedGet = Symbol("indexed property get");
|
||||
const indexedSetNew = Symbol("indexed property set new");
|
||||
const indexedSetExisting = Symbol("indexed property set existing");
|
||||
const namedGet = Symbol("named property get");
|
||||
const namedSetNew = Symbol("named property set new");
|
||||
const namedSetExisting = Symbol("named property set existing");
|
||||
const namedDelete = Symbol("named property delete");
|
||||
|
||||
module.exports = exports = {
|
||||
isObject,
|
||||
hasOwn,
|
||||
getOwnPropertyDescriptors,
|
||||
wrapperSymbol,
|
||||
implSymbol,
|
||||
getSameObject,
|
||||
wrapperForImpl,
|
||||
implForWrapper,
|
||||
tryWrapperForImpl,
|
||||
tryImplForWrapper,
|
||||
iterInternalSymbol,
|
||||
IteratorPrototype,
|
||||
isArrayIndexPropName,
|
||||
supportsPropertyIndex,
|
||||
supportedPropertyIndices,
|
||||
supportsPropertyName,
|
||||
supportedPropertyNames,
|
||||
indexedGet,
|
||||
indexedSetNew,
|
||||
indexedSetExisting,
|
||||
namedGet,
|
||||
namedSetNew,
|
||||
namedSetExisting,
|
||||
namedDelete
|
||||
};
|
Reference in New Issue
Block a user