1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Fix display_svg_spec tests.

- Mark the test as async, and don't swallow exceptions.
- Fix the DOMElement polyfill to behave closer to the actual getAttributeNS
  method, which excludes the namespace prefix.
This commit is contained in:
Rob Wu 2017-07-14 18:55:17 +02:00
parent ca3c08f12b
commit 18566091aa
2 changed files with 43 additions and 21 deletions

View file

@ -60,7 +60,22 @@ function DOMElement(name) {
DOMElement.prototype = {
getAttributeNS: function DOMElement_getAttributeNS(NS, name) {
return name in this.attributes ? this.attributes[name] : null;
// Fast path
if (name in this.attributes) {
return this.attributes[name];
}
// Slow path - used by test/unit/display_svg_spec.js
// Assuming that there is only one matching attribute for a given name,
// across all namespaces.
if (NS) {
var suffix = ':' + name;
for (var fullName in this.attributes) {
if (fullName.slice(-suffix.length) === suffix) {
return this.attributes[fullName];
}
}
}
return null;
},
setAttributeNS: function DOMElement_setAttributeNS(NS, name, value) {