Permalink
Browse files

Updating the elements creation to use the new Slick.Parser classList …

…property instead of classes. Improved the attributes creation by iterating over the attributes array instead of the parts array.
  • Loading branch information...
fabiomcosta authored and cpojer committed May 10, 2010
1 parent 9887194 commit 3e5624c4fc2c3c1fcaff59a1f919bfb613dd1ec5
Showing with 7 additions and 6 deletions.
  1. +7 −6 Source/Element/Element.js
View
@@ -25,14 +25,15 @@ var Element = function(tag, props){
var parsed = Slick.parse(tag).expressions[0][0];
tag = (parsed.tag == '*') ? 'div' : parsed.tag;
if (parsed.id && props.id == null) props.id = parsed.id;
-
- for (var i = 0, l = parsed.parts.length; i < l; i++){
- var part = parsed.parts[i];
- if (part.type == 'attribute' && part.value != null && part.operator == '=' && props[part.key] == null)
- props[part.key] = part.value;
+
+ var attributes = parsed.attributes;
+ if (attributes) for (var i = 0, l = attributes.length; i < l; i++){
+ var attr = attributes[i];
+ if (attr.value != null && attr.operator == '=' && props[attr.key] == null)
+ props[attr.key] = attr.value;
}
- if (parsed.classes && props['class'] == null) props['class'] = parsed.classes.join(' ');
+ if (parsed.classList && props['class'] == null) props['class'] = parsed.classList.join(' ');
}
return document.newElement(tag, props);

0 comments on commit 3e5624c

Please sign in to comment.