Commits

Rune Halvorsen committed 13d0e22

Added tests and js implementation for boolean attributes on elements.

Comments (0)

Files changed (3)

 Todo
 ----
 
+- docs for interpolation
 - shorthand for single child textnode?
 - spaces in class list should be removed
 - posargs
         attrtoken = _strip(attrtoken.slice(1, -1));
         var pairs = attrtoken.split(/\s*,\s*/).map(function(e) { return e.split(/\s*=\s*/) });
         pairs.forEach(function(pair) {
-            attrs[pair[0]] = _interpolate(pair[1], env);
+            attrs[pair[0]] = _interpolate(pair[1] || "", env);
         })
 
         return attrs;

test/linenoise-test.js

         assert.equals(ele.getAttribute("data-foo"), "test");
     },
 
-    "attribute resolution": function() {
+    "property resolution": function() {
         var data = {"foo": {bar: "baz", meh: {qux: "phlebotinum"}}};
 
         var html = makeMarkup('"{foo.bar}"', data);
 
         var html = makeMarkup('"{foo.meh.qux}"', data);
         assert.equals(html, "phlebotinum");
+    },
+
+    "boolean attributes": function() {
+        var html = makeMarkup("a[checked]");
+        assert.equals(html, '<a checked=""></a>');
+
+        var html = makeMarkup("a[checked, ready]");
+        assert.equals(html, '<a checked="" ready=""></a>');
     }
 
 });