mauricemach / coffeekup

Markup as CoffeeScript.
coffeekup.org
MIT License
1.26k stars 83 forks source link

element id shorthand doesn't work client side on IE7 #96

Open hankmander opened 12 years ago

hankmander commented 12 years ago

the coffekup code: div "#my_id", -> gives: <DIV class="#my_id"> instead of giving the element an id it gives the element a class that starts with a '#'. However, it works if you do this instead: div id: "register_interest", ->

giving elements classes ( div ".my_id", -> ) works as expected though.

NOTE. This only occurs when client side rendering a template in Internet explorer 7. Might apply to other versions of IE as well.

Edit: version 0.3.1 of coffeekup and 1.1.2 of coffeescript used

hankmander commented 12 years ago

Seems like it's the same with current versions of Opera.

treeform commented 12 years ago

I have the same issue with IE8

treeform commented 12 years ago

fix here:

@@ -126,10 +126,12 @@ skeleton = (data = {}) ->
       classes = []

       for i in str.split '.'
-        if '#' in i
-          id = i.replace '#', ''
+        if i.length == 0
+          continue
+        if "#" == i[0]
+          id = i.slice 1
         else
-          classes.push i unless i is ''
+          classes.push i

       text " id=\"#{id}\"" if id

I restricted it to hash in the beginning only. Moved empty string check up.