Eric said:
Using the DOM module at
<
http://www.cinsoft.net/mylib-builder.asp>
and given
<input readonly>
as the first element of type INPUT in a HTML context,
API.getAttribute(
document.getElementsByTagName('INPUT')[0],
'readonly'
)
Sorry for the late response. Just happened to stumble over this.
returns an empty string in Firefox 3.5, Opera 10.10, Safari 4, Google
Chrome 4 beta (all on OS X) and Internet Explorer < 8.
That's exactly right (and all but IE are doing that on their own as the
wrapper at that time did virtually nothing in the quasi-standards fork).
It's not:-
<input readonly="readonly">
....though they mean the same thing, of course.
And I have since forced IE8 standards mode to do the same thing to give
a consistent interface (an inconsistent interface would clearly be
poison for such attributes--see YUI, jQuery, etc.)
What would you have it do? I know the specs say something different,
but none of the browsers over the years have implemented attributes per
the specs (and in places the specs make no sense anyway). As an example
nonsense, they say to return an empty string for _any_ attribute that is
absent. I am certainly glad the browser developers came up with a
better plan than that (e.g. returning null for that case).
At the end of the day, what matters for wrappers is a consistent
interface. They are, after all, wrappers. There is no pretense that
they are to behave identically to the host methods (unless you consider
such monstrosities as Base2).
http://www.cinsoft.net/attributes.html
....which has since been pasted over the old My Library attribute methods.
Amazingly IE 8 seems to be the only browser to get the getAttribute
method of the Element interface right (in this respect), and that
even without using any wrapper methods. Bummer
But in getting it right (technically right per the specs), in practical
terms they got it wrong as over a decade of history contradicts them, so
they have created problems for no reason. Furthermore, they return null
for virtually all of the other attributes when missing, which history
(and common sense) says is right, but the specs say is wrong. I would
have certainly preferred they return null for missing attributes,
period. but it doesn't really matter as the wrapper smooths that out
per _my_ specs (it's not a browser host method, so mine are the only
specs that matter).