Comparing version 2.2.1 to 3.0.0
@@ -0,1 +1,27 @@ | ||
<a name="3.0.0"></a> | ||
# [3.0.0](https://github.com/lddubeau/saxes/compare/v2.2.1...v3.0.0) (2018-08-21) | ||
### Features | ||
* process the xmlns attribute the customary way ([2c9672a](https://github.com/lddubeau/saxes/commit/2c9672a)) | ||
### BREAKING CHANGES | ||
* In previous versions the attribute `xmlns` (as in `<foo xmlns="some-uri">` would | ||
be reported as having the prefix `"xmlns"` and the local name `""`. This | ||
behavior was inherited from sax. There was some logic to it, but this behavior | ||
was surprising to users of the library. The principle of least surprise favors | ||
eliminating that surprising behavior in favor of something less surprising. | ||
This commit makes it so that `xmlns` is not reported as having a prefix of `""` | ||
and a local name of `"xmlns"`. This accords with how people interpret attribute | ||
names like `foo`, `bar`, `moo` which all have no prefix and a local name. | ||
Code that deals with namespace bindings or cares about `xmlns` probably needs to | ||
be changed. | ||
<a name="2.2.1"></a> | ||
@@ -2,0 +28,0 @@ ## [2.2.1](https://github.com/lddubeau/saxes/compare/v2.2.0...v2.2.1) (2018-08-20) |
@@ -1599,7 +1599,5 @@ "use strict"; | ||
* | ||
* @param {boolean} [attribute=false] Whether we are in an attribute. | ||
* | ||
* @returns {{prefix: string, local: string}} | ||
*/ | ||
qname(name, attribute) { | ||
qname(name) { | ||
const colon = name.indexOf(":"); | ||
@@ -1610,11 +1608,4 @@ let prefix; | ||
if (colon < 0) { | ||
// <x "xmlns"="http://foo"> | ||
if (attribute && name === "xmlns") { | ||
prefix = "xmlns"; | ||
local = ""; | ||
} | ||
else { | ||
prefix = ""; | ||
local = name; | ||
} | ||
prefix = ""; | ||
local = name; | ||
} | ||
@@ -1647,6 +1638,9 @@ else { | ||
for (const [name, uri] of attribList) { | ||
const { prefix, local } = this.qname(name, true); | ||
const { prefix, local } = this.qname(name); | ||
if (prefix === "xmlns") { | ||
ns[local] = uri.trim(); | ||
} | ||
else if (name === "xmlns") { | ||
ns[""] = uri.trim(); | ||
} | ||
} | ||
@@ -1680,3 +1674,9 @@ | ||
const { prefix, local } = this.qname(name, true); | ||
const uri = prefix === "" ? "" : (this.resolve(prefix) || ""); | ||
let uri; | ||
if (prefix === "") { | ||
uri = (name === "xmlns") ? XMLNS_NAMESPACE : ""; | ||
} | ||
else { | ||
uri = this.resolve(prefix) || ""; | ||
} | ||
const a = { | ||
@@ -1683,0 +1683,0 @@ name, |
@@ -5,3 +5,3 @@ { | ||
"author": "Louis-Dominique Dubeau <ldd@lddubeau.com>", | ||
"version": "2.2.1", | ||
"version": "3.0.0", | ||
"main": "lib/saxes.js", | ||
@@ -8,0 +8,0 @@ "types": "lib/saxes.d.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77498