ded / bonzo

library agnostic, extensible DOM utility
Other
1.32k stars 137 forks source link

Getting the `value` attribute of a `<data>` element returned undefined #40

Closed Calvein closed 12 years ago

ded commented 13 years ago

this more than likely happens on all HTML5 elements.. :/

Calvein commented 13 years ago

The spec allow the value attribute only on <li> in <ol>s and <data>. I have fix my problem on the <data> by doing this because bonzo doesn't check the case sensitivity on specialAttributes : $('data').attr('Value')

rvagg commented 13 years ago

@Calvein can you write a test or two for it? Just fiddling in Chrome I can see that (<data>).value gives undefined while (<data>).getAttribute('value') gives the attribute value which is where attr() is tripping up for you but <li> seems to work OK wtih just .value (or ['value']). Would be good to see it across browsers. Would also be good to fix the case sensitivity thing too, perhaps a toLowerCase() rather than fixing the regex cause I think the spec wants lower case attribute keys anyway?

Calvein commented 13 years ago

In IE8 li.value or li['value'] returns a boolean not the correct value. For the case sensitivity issue, we may just add an i at the end of the specialAttributes variable: /^checked|value|selected$/i

I'll do the test later :)

ded commented 12 years ago

hey there @Calvein — i'm going through some old requests, if you'd like this one in, would you mind isolating your edits to src/bonzo.js and of course, keep your added tests? as it stands it conflicts with master. cc @rvagg

Calvein commented 12 years ago

I think it would be better to wait for the <data> element to be in the spec (http://dev.w3.org/html5/spec/the-data-element.html) and not only in the whatwg (http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-data-element), I'm not sure if it will stay because of the come back of the <time> element.