I suggest you read this thread again. I'd like to hear your concept
Actually, I meant this thread:
http://groups.google.com/group/comp.lang.javascript/browse_thread/thread/95c4bbfe39f19ce4#
I presume you missed it.
So, assuming you are not up to the task of explaining (in simple
terms) what this lynch-pin method does, I'll try to give you a head
start. You can't fix it if you don't understand what it does (and
what it should be doing.) One could argue that you shouldn't use or
recommend something you don't understand, but we've been over that ad
nauseum. Consider this the final exam for your credibility.
In jQuery, the attr method will do one of the following, depending on
its arguments:
1. Get a DOM property
2. Set a DOM property
3. Get an attribute
4. Set an attribute
The course taken depends on:
1. DOM type (XML or HTML)
2. Element type
3. Browser
4. jQuery version
The first argument is an attribute name, which jQuery might mutate,
depending on:
1. An incomplete list of properties, which changes per version
2. Nothing else.
The second point alludes to the fact that the attr method couldn't
care less about the second argument, which is completely
undocumented. The decision about when to use get/setAttribute or not
(remember the name is already mutated) is unrelated to the "black
list" result, allowing all sorts of invalid names and/or values to
slip through. Get it?
In other words, at a glance, what do these do?
$(el).attr('disabled', 'disabled');
$(el).attr('disabled', true);
As expected, the results vary as described above. Contrast that with:
el.disabled = true;
How about these?
$(el).attr('onclick', 'alert("test")');
$(el).attr('onclick', function() { alert('test'); });
Contrast with:
el.onclick = function() { alert('test'); };
Bonus question, what would this be expected to return?
${el).attr('rowspan');
What about this?
${el).attr('rowSpan');
That's why I'd never read your code (or anything like it.) Confronted
with such illegible nonsense, it is best to throw it away and start
over (losing at least 50K in the process.)
Regardless of any of this, this outrageous over-complication was never
needed. You've got four functions here (getProperty, setProperty,
getAttribute, setAttribute) and two are rarely needed in an HTML DOM.
Resig has mashed them all up into one idiotic function, which can't do
any of them right. He runs this crap through his crystal ball (a
patchwork quilt of unit tests that mirror his meanderings and
misconceptions), pronounces it as "working" and now half the Web is
running on his latest attempt to "pave over" differences in browsers.
So what does "moving in the right direction" mean to... anybody? Do
you mark your calendar to deploy jQuery a year from now, assuming
Resig will figure out his mistakes by then? Are you a glutton for
upgrades? BTW, have *you* even upgraded yet? If not, you best stop
wasting time on futile arguments.
Why would anyone start out in browser scripting trying to learn the
attr method when even the author is clueless about its purpose, as
well as its execution (and there are much simpler and more concise
techniques to be found in Javascript?) Ironic that those who peddle
paranoia about browser differences could be so completely unable to
deal with them.
Anyway, I await your explanation of the attr method and just what
makes it so simple and concise.