Skip to content

Commit

Permalink
#1872: map attribute 'for' to 'htmlFor' property
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyavf committed Sep 15, 2015
1 parent 1721ea2 commit 5a3480e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions util/attr/attr.js
Expand Up @@ -42,6 +42,7 @@ steal("can/util/can.js", function (can) {
"value": "value",
"innertext": "innerText",
"textcontent": "textContent",
"for": "htmlFor",
"checked": true,
"disabled": true,
"readonly": true,
Expand Down
21 changes: 21 additions & 0 deletions util/attr/attr_test.js
Expand Up @@ -84,6 +84,27 @@ steal('can/util', 'can/view/mustache', 'can/util/attr', 'steal-qunit', function
can.remove(can.$("#qunit-fixture>*"));
});

test("Map special attributes", function () {

var div = document.createElement("div");

document.getElementById("qunit-fixture").appendChild(div);

can.attr.set(div, "class", "my-class");
equal(div.className, "my-class", "Map class to className");

can.attr.set(div, "for", "my-for");
equal(div.htmlFor, "my-for", "Map for to htmlFor");

can.attr.set(div, "innertext", "my-inner-text");
equal(div.innerText, "my-inner-text", "Map innertext to innerText");

can.attr.set(div, "textcontent", "my-content");
equal(div.textContent, "my-content", "Map textcontent to textContent");

can.remove(can.$("#qunit-fixture>*"));
});

if (window.jQuery || window.Zepto) {

test("zepto or jQuery - bind and unbind", function () {
Expand Down
10 changes: 10 additions & 0 deletions util/attr/test.html
@@ -0,0 +1,10 @@
<!doctype html>
<html>
<head> </head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="../../node_modules/steal/steal.js"
data-main="util/attr/attr_test"></script>
</body>
</html>

0 comments on commit 5a3480e

Please sign in to comment.