Permalink
Browse files

squashed commits for issue 105 - test for numeric attributes

  • Loading branch information...
1 parent 16e7df7 commit e797dd450cd800f93a102743a556a44899acc4f2 ironchefpython committed Oct 3, 2012
Showing with 9 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +1 −1 lib/utils.js
  3. +7 −0 test/api.attributes.js
View
1 .gitignore
@@ -5,3 +5,4 @@ coverage.html
lib-cov
.coverage_data
cover_html
+.c9revisions
View
2 lib/utils.js
@@ -26,5 +26,5 @@ exports.isTag = function(type) {
* 0 = XML, 1 = HTML4 and 2 = HTML5
*/
-exports.encode = function(str) { return entities.encode(str, 0); };
+exports.encode = function(str) { return entities.encode(String(str), 0); };
exports.decode = function(str) { return entities.decode(str, 2); };
View
7 test/api.attributes.js
@@ -52,6 +52,13 @@ describe('$(...)', function() {
$apple.attr('href', 'http://github.com/"><script>alert("XSS!")</script><br');
expect($apple.html()).to.not.contain('<script>alert("XSS!")</script>');
});
+
+ it('(key, value) : should coerce values to a string', function() {
+ var $apple = $('.apple', fruits);
+ $apple.attr('data-test', 1);
+ expect($apple[0].attribs['data-test']).to.equal('1');
+ expect($apple.attr('data-test')).to.equal('1');
+ });
});
describe('.removeAttr', function() {

0 comments on commit e797dd4

Please sign in to comment.