w3c-xmlserializer
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -229,3 +229,7 @@ "use strict"; | ||
} | ||
map[ns].push(prefix); | ||
if (map[ns]) { | ||
map[ns].push(prefix); | ||
} else { | ||
map[ns] = [prefix]; | ||
} | ||
qualifiedName = prefix + ":" + node.localName; | ||
@@ -232,0 +236,0 @@ markup += `${qualifiedName} xmlns:${prefix}="${attributeUtils.serializeAttributeValue( |
@@ -12,2 +12,27 @@ "use strict"; | ||
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"); | ||
@@ -81,2 +106,3 @@ const implSymbol = Symbol("impl"); | ||
hasOwn, | ||
getOwnPropertyDescriptors, | ||
wrapperSymbol, | ||
@@ -83,0 +109,0 @@ implSymbol, |
@@ -8,48 +8,32 @@ "use strict"; | ||
function XMLSerializer() { | ||
if (new.target === undefined) { | ||
throw new TypeError( | ||
"Failed to construct 'XMLSerializer'. Please use the 'new' operator; this constructor " + | ||
"cannot be called as a function." | ||
); | ||
class XMLSerializer { | ||
constructor() { | ||
return iface.setup(Object.create(new.target.prototype)); | ||
} | ||
iface.setup(this); | ||
} | ||
serializeToString(root) { | ||
if (!this || !module.exports.is(this)) { | ||
throw new TypeError("Illegal invocation"); | ||
} | ||
Object.defineProperty(XMLSerializer, "prototype", { | ||
value: XMLSerializer.prototype, | ||
writable: false, | ||
enumerable: false, | ||
configurable: false | ||
}); | ||
XMLSerializer.prototype.serializeToString = function 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); | ||
} | ||
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.defineProperty(XMLSerializer.prototype, Symbol.toStringTag, { | ||
value: "XMLSerializer", | ||
writable: false, | ||
enumerable: false, | ||
configurable: true | ||
} | ||
Object.defineProperties(XMLSerializer.prototype, { | ||
serializeToString: { enumerable: true }, | ||
[Symbol.toStringTag]: { value: "XMLSerializer", configurable: true } | ||
}); | ||
const iface = { | ||
@@ -114,4 +98,2 @@ // When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()` | ||
value: new Impl.implementation(constructorArgs, privateData), | ||
writable: false, | ||
enumerable: false, | ||
configurable: true | ||
@@ -118,0 +100,0 @@ }); |
{ | ||
"name": "w3c-xmlserializer", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
21896
737
1