Skip to content

Commit

Permalink
Oh, turns out attribute names are case sensitive, even in HTML docume…
Browse files Browse the repository at this point in the history
…nts.
  • Loading branch information
papandreou committed May 8, 2015
1 parent 854d41b commit 443c0ac
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,16 +506,9 @@ module.exports = {
} else if (expectedAttributes && typeof expectedAttributes === 'object') {
expectedValueByAttributeName = expectedAttributes;
}
var expectedValueByLowerCasedAttributeName = {};
Object.keys(expectedValueByAttributeName).forEach(function (attributeName) {
var lowerCasedAttributeName = attributeName.toLowerCase();
expectedAttributeNames.push(lowerCasedAttributeName);
if (expectedValueByLowerCasedAttributeName.hasOwnProperty(lowerCasedAttributeName)) {
throw new Error('Duplicate expected attribute with different casing: ' + attributeName);
}
expectedValueByLowerCasedAttributeName[lowerCasedAttributeName] = expectedValueByAttributeName[attributeName];
expectedAttributeNames.push(attributeName);
});
expectedValueByAttributeName = expectedValueByLowerCasedAttributeName;

expectedAttributeNames.forEach(function (attributeName) {
var attributeValue = subject.getAttribute(attributeName);
Expand Down Expand Up @@ -590,8 +583,7 @@ module.exports = {
canContinueLine = false;
}
Object.keys(attrs).forEach(function (attributeName) {
var lowerCaseAttributeName = attributeName.toLowerCase();
var promise = promiseByKey.attributes[lowerCaseAttributeName];
var promise = promiseByKey.attributes[attributeName];
output.sp(canContinueLine ? 1 : 2 + subject.nodeName.length);
writeAttributeToMagicPen(output, attributeName, attrs[attributeName], isHtml);
if ((promise && promise.isFulfilled()) || (!promise && (!onlyAttributes || expectedAttributeNames.indexOf(attributeName) !== -1))) {
Expand Down

0 comments on commit 443c0ac

Please sign in to comment.