Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #15986 > unrolled thread
| Started by | David Mark <dmark.cinsoft@gmail.com> |
|---|---|
| First post | 2012-09-18 22:57 -0700 |
| Last post | 2012-09-19 20:13 -0700 |
| Articles | 11 on this page of 31 — 7 participants |
Back to article view | Back to comp.lang.javascript
jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-18 22:57 -0700
Re: jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-19 03:21 -0700
Re: jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-19 12:47 -0700
Re: jQuery still (very) confused about attributes and properties John G Harris <john@nospam.demon.co.uk> - 2012-09-19 15:43 +0100
Re: jQuery still (very) confused about attributes and properties "S.T." <anon@anon.com> - 2012-09-19 08:33 -0700
Re: jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-19 11:32 -0700
Re: jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-19 12:23 -0700
Re: jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-19 11:20 -0700
Re: jQuery still (very) confused about attributes and properties Hans-Georg Michna <hans-georgNoEmailPlease@michna.com> - 2012-09-19 17:34 +0200
Re: jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-19 11:44 -0700
Re: jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-19 12:16 -0700
Re: jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-19 12:51 -0700
Re: jQuery still (very) confused about attributes and properties "S.T." <anon@anon.com> - 2012-09-19 14:26 -0700
Re: jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-19 14:59 -0700
Re: jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-19 15:13 -0700
Re: jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-19 15:28 -0700
Re: jQuery still (very) confused about attributes and properties "S.T." <anon@anon.com> - 2012-09-19 15:30 -0700
Re: jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-19 16:01 -0700
Re: jQuery still (very) confused about attributes and properties "S.T." <anon@anon.com> - 2012-09-19 17:09 -0700
Re: jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-19 17:23 -0700
Re: jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-19 22:17 -0700
Re: jQuery still (very) confused about attributes and properties "S.T." <anon@anon.com> - 2012-09-20 10:41 -0700
Re: jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-20 11:00 -0700
Re: jQuery still (very) confused about attributes and properties John G Harris <john@nospam.demon.co.uk> - 2012-09-21 09:19 +0100
Re: jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-21 06:29 -0700
Re: jQuery still (very) confused about attributes and properties Adam Silver <adambsilver@gmail.com> - 2012-09-21 07:08 -0700
Re: jQuery still (very) confused about attributes and properties Andrew Poulos <ap_prog@hotmail.com> - 2012-09-20 15:47 +1000
Re: jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-19 23:16 -0700
Re: jQuery still (very) confused about attributes and properties Gene Wirchenko <genew@ocis.net> - 2012-09-20 10:20 -0700
Re: jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-19 16:03 -0700
Re: jQuery still (very) confused about attributes and properties David Mark <dmark.cinsoft@gmail.com> - 2012-09-19 20:13 -0700
Page 2 of 2 — ← Prev page 1 [2]
| From | David Mark <dmark.cinsoft@gmail.com> |
|---|---|
| Date | 2012-09-19 22:17 -0700 |
| Message-ID | <9908c408-fc6c-4eaf-b7a1-492c8d635fc1@r7g2000yqa.googlegroups.com> |
| In reply to | #16024 |
On Sep 19, 8:09 pm, "S.T." <a...@anon.com> wrote: > On 9/19/2012 4:01 PM, David Mark wrote: > > > Virtually everybody on the planet (save for you) is aware > > of my contributions to jQuery > > Um, no. You seem to hypothesize that you've been a driving force behind > changes to the most popular library out there but there are very few, if > any, who would agree with you. Sorry bro. :( > Now that my "bro" has (hopefully) scuttled off, here are some links that provide insight into the history of jQuery development, with regard to attributes, properties, feature detection (and more!) :) My proxy (Matt Kruse) makes yet another impassioned pitch for them to pay attention to the difference between attributes and properties: https://groups.google.com/group/jquery-dev/browse_thread/thread/baef5e91bd714033 ...that one references the Attributes primer and shows Resig clumsily copying the code and then trying to test jQuery with it (despite it being inappropriate for use with jQuery as is). Bizarre SELECT hack: https://groups.google.com/group/jquery-dev/browse_frm/thread/fe658871a8bff208/bb0d17776314606a?lnk=gst&q=broken+select#bb0d17776314606a "After some discussion with colleagues, a better approach has been identified." Uh, colleague (singular) as I recall. At least part of that eventually made it into jQuery as a patch. I remember as my buddy Matt begrudgingly gave me credit as an "official" jQuery contributor at that point. :) Here's their original reaction to the first review from back in 2007. Yeah, they don't appear influenced at all. :) https://groups.google.com/group/jquery-dev/browse_frm/thread/bc0ce94f8b967224/92767115a8cf78a8?#92767115a8cf78a8 Towards the end: "P.S. In his recent posts over on c.l.j he's actually been much more down to earth and given specific examples of what's wrong and even one detailed description on his approach to one of the issues. *ducks for cover*" The "detailed description" he refers to is the very test that enabled them to ditch a critical bit of browser sniffing and put them on the road to (attempted) feature testing/detection. I know Resig had never heard of an attribute reflection test at this time (neither had Peter Michaux as I recall). In fact, this test is undisputedly my invention as there's never been any evidence that such a test was used prior to my introducing it in 2007. As a side note, it's a big part of Modernizr (sp?) as well, but I'll give credit to their authors for honestly acknowledging my influence (on Twitter IIRC). There'd sure be no Modernizr without that pattern. Hell, it's clear from his code (and confusion) that Resig didn't know attributes from properties at all at that time. This is the now infamous "magic flag" that he wanted so he could eliminate the browser sniffing in the "attr" function. And yes, he copied it. It showed up a year later, virtually verbatim, in version 1.3. He didn't read it (along with dozens of his team members), discuss it in his forum, forget all about it and then invent it himself a year later. ;) That's just one of several discussions that occurred between members of the jQuery team, in their own developer forum in the months that followed the 2007 review. Not coincidentally, this is also about the time My Library was first published, but I'm sure they simply ignored it, just like the review. IIRC, Resig indicated he really wanted to see "my perfect library" in the review thread. He saw such a thing as a yeti. Five years later and the yeti has certainly been spotted, alive and well. :) http://www.youtube.com/watch?v=6RexQLrcqwc&feature=player_detailpage#t=43s The CLJ thread referenced throughout the jQuery developer discussion: https://groups.google.com/group/comp.lang.javascript/browse_thread/thread/415949d1bcce6e6a/03c4d326340e7f7d?#03c4d326340e7f7d Reaction from Richard Cornford regarding the 1.3 transformation that followed a year later: https://groups.google.com/group/comp.lang.javascript/msg/8ee3b684baaa0baa One from CLJ that was referenced in one of the above-mentioned jQuery forum posts: https://groups.google.com/group/comp.lang.javascript/browse_frm/thread/d2c0407a7fc2e33a/ Was a real pain digging these up (forgot they were in the jQuery *dev* group, not the main one). As a side note, jQuery's new forum is broken beyond belief in Chrome. Words can't express how broken; every click (or navigation) is an adventure and many of the imported legacy posts are full of broken markup. Another sound move on their part. :) Now, if history holds, "S.T." will shut up at this point and then pop up to voice his, uh "skepticism" a month from now as if he has a case of amnesia. He's like some sort of obsessed stalker who wants to make sure that his heroes gets credit that they clearly do not deserve. Some life. :(
[toc] | [prev] | [next] | [standalone]
| From | "S.T." <anon@anon.com> |
|---|---|
| Date | 2012-09-20 10:41 -0700 |
| Message-ID | <505b5533$0$65531$742ec2ed@news.sonic.net> |
| In reply to | #16031 |
On 9/19/2012 10:17 PM, David Mark wrote: > Now, if history holds, "S.T." will shut up at this point and then pop > up to voice his, uh "skepticism" a month from now as if he has a case > of amnesia. No such luck. :) Your whole premise is ridiculous. You've spent an extraordinary amount of time pretending to prove a mirage. jQuery's attr() and prop() methods are not constructed in the manner you would have - you make that clear every couple days. Virtually nothing in jQuery has been done in a manner you find acceptable. You've made that clear virtually daily, in one venue or another, for the past *five* years. Yet now you claim that the jQuery team is secretly following your, err... 'suggestions'. This despite the fact for five years they've disregarded the overwhelming majority of things you've said, and those few instances where they've revisited things you've (correctly) screeched should be revisited, and should be revisited (incorrectly) immediately, these few instances occur literally years after the fact. And yet, somehow, you seem to really believe your input has a real bearing in their design process. You don't think they're making these fixes because *it's how the DOM actually works* and low-priority bugs with backwards compatibility concerns to an a user base in the hundreds of thousands and tens of millions of websites can take time to fix. But rather you claim they're *really* making these changes because you're telling them too but they don't really want to though they know they should, so they hold off until you finally embarrass them into making the changes you're calling behind the scenes. It's freaking crazy man.
[toc] | [prev] | [next] | [standalone]
| From | David Mark <dmark.cinsoft@gmail.com> |
|---|---|
| Date | 2012-09-20 11:00 -0700 |
| Message-ID | <153c9e90-2234-43f6-993a-71c294bedf5c@googlegroups.com> |
| In reply to | #16052 |
On Thursday, September 20, 2012 1:41:08 PM UTC-4, S.T. wrote: > On 9/19/2012 10:17 PM, David Mark wrote: > > > Now, if history holds, "S.T." will shut up at this point and then pop > > > up to voice his, uh "skepticism" a month from now as if he has a case > > > of amnesia. > > > > No such luck. :) > > > > Your whole premise is ridiculous. You've spent an extraordinary amount > > of time pretending to prove a mirage. If you say so. > > > > jQuery's attr() and prop() methods are not constructed in the manner you > > would have - you make that clear every couple days. No, they clearly tried to take my advice, but predictably botched the job. > Virtually nothing in > > jQuery has been done in a manner you find acceptable. That's the first true statement you've made in this thread. > You've made that > > clear virtually daily, in one venue or another, for the past *five* years. Again, if you say so. :) > > > > Yet now you claim that the jQuery team is secretly following your, > > err... 'suggestions'. It's clearly no secret (see links). [snip redundant blithering] > > > > You don't think they're making these fixes because *it's how the DOM > > actually works* WRT to "attr", it should be clear who showed them how the "DOM actually works" (among other things). > and low-priority bugs with backwards compatibility > > concerns to an a user base in the hundreds of thousands and tens of > > millions of websites can take time to fix. You simply aren't paying attention. For one, "attr" is part of their foundation and used by virtually every jQuery script out there. So not a low priority. And two, the extant "attr" is not consistent, even in the browsers they claim to support. And finally, as I've recommended repeatedly, they just needed to deprecate (and eventually remove) that method. They could have done that five years ago and certainly had serviceable methods by now. Unfortunately, they aren't paying close attention either. [more blithering] > > > > It's freaking crazy man. Dave's not here, man. Go away. :)
[toc] | [prev] | [next] | [standalone]
| From | John G Harris <john@nospam.demon.co.uk> |
|---|---|
| Date | 2012-09-21 09:19 +0100 |
| Message-ID | <Ci5BQSD0LCXQFwBM@J.A830F0FF37FB96852AD08924D9443D28E23ED5CD> |
| In reply to | #16052 |
On Thu, 20 Sep 2012 at 10:41:30, in comp.lang.javascript, S.T. wrote: >On 9/19/2012 10:17 PM, David Mark wrote: <snip> >Yet now you claim that the jQuery team is secretly following your, >err... 'suggestions'. This despite the fact for five years they've >disregarded the overwhelming majority of things you've said, and those >few instances where they've revisited things you've (correctly) >screeched should be revisited, and should be revisited (incorrectly) >immediately, these few instances occur literally years after the fact. >And yet, somehow, you seem to really believe your input has a real >bearing in their design process. <snip> Not only that, but when the JQuery people eventually admit that JQuery is far too slow to load then *I* shall claim the credit for persuading them. Equally, when web designers admit that having different releases of JQuery on the same web site is a maintenance disaster then I shall claim the credit for making them aware of this. John -- John Harris
[toc] | [prev] | [next] | [standalone]
| From | David Mark <dmark.cinsoft@gmail.com> |
|---|---|
| Date | 2012-09-21 06:29 -0700 |
| Message-ID | <3ee005ca-4f64-4b3f-8a5e-5aa16d724e61@v15g2000yqi.googlegroups.com> |
| In reply to | #16074 |
On Sep 21, 4:19 am, John G Harris <j...@nospam.demon.co.uk> wrote: > On Thu, 20 Sep 2012 at 10:41:30, in comp.lang.javascript, S.T. wrote: > >On 9/19/2012 10:17 PM, David Mark wrote: > > <snip>>Yet now you claim that the jQuery team is secretly following your, > >err... 'suggestions'. This despite the fact for five years they've > >disregarded the overwhelming majority of things you've said, and those > >few instances where they've revisited things you've (correctly) > >screeched should be revisited, and should be revisited (incorrectly) > >immediately, these few instances occur literally years after the fact. > >And yet, somehow, you seem to really believe your input has a real > >bearing in their design process. > > <snip> > > Not only that, but when the JQuery people eventually admit that JQuery > is far too slow to load then *I* shall claim the credit for persuading > them. Have you mentioned that to them? You might have company there. :) Anyway, I don't really persuade, I make the issues so public that they have no choice but to confront them. Though I suppose the blatant feature testing ripoffs were a matter of "persuasion" (followed by plagiarism). That one didn't take "literally years" to happen. :( > > Equally, when web designers admit that having different releases of > JQuery on the same web site is a maintenance disaster then I shall claim > the credit for making them aware of this. > Hard to believe anyone would do that (though I've seen it on occasion). Just goes to show that some designers are completely oblivious to the ramifications of pasting in random scripts.
[toc] | [prev] | [next] | [standalone]
| From | Adam Silver <adambsilver@gmail.com> |
|---|---|
| Date | 2012-09-21 07:08 -0700 |
| Message-ID | <93750808-33b6-4f33-b6ac-4ab926bbe940@u9g2000vbm.googlegroups.com> |
| In reply to | #16075 |
On Sep 21, 2:29 pm, David Mark <dmark.cins...@gmail.com> wrote: > On Sep 21, 4:19 am, John G Harris <j...@nospam.demon.co.uk> wrote: > > Equally, when web designers admit that having different releases of > > JQuery on the same web site is a maintenance disaster then I shall claim > > the credit for making them aware of this. > > Hard to believe anyone would do that (though I've seen it on > occasion). Just goes to show that some designers are completely > oblivious to the ramifications of pasting in random scripts. I have experienced that also. It wasn't the nicest mess to clear up :(
[toc] | [prev] | [next] | [standalone]
| From | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| Date | 2012-09-20 15:47 +1000 |
| Message-ID | <Vp6dnctyCaF9MMfNnZ2dnUVZ_hSdnZ2d@westnet.com.au> |
| In reply to | #16024 |
On 20/09/2012 10:09 AM, S.T. wrote: > On 9/19/2012 4:01 PM, David Mark wrote: > >> Virtually everybody on the planet (save for you) is aware >> of my contributions to jQuery > > Um, no. You seem to hypothesize that you've been a driving force behind > changes to the most popular library out there but there are very few, if > any, who would agree with you. Sorry bro. :( > >> Dojo > > I recall reading your contributions to Dojo in the past, on their > mailing list. Very amusing stuff. :) > > Are we done yet? DM obviously understands js better than most. He posts links to discussions, code, and other references in support of his statements yet you reply with argumentum ad hominem. Do you believe your replies make you look a winner? Andrew Poulos
[toc] | [prev] | [next] | [standalone]
| From | David Mark <dmark.cinsoft@gmail.com> |
|---|---|
| Date | 2012-09-19 23:16 -0700 |
| Message-ID | <e9b0c8d5-cbc2-4b3d-8362-a6de521a87f3@f6g2000yqi.googlegroups.com> |
| In reply to | #16032 |
On Sep 20, 1:47 am, Andrew Poulos <ap_p...@hotmail.com> wrote: > On 20/09/2012 10:09 AM, S.T. wrote: > > > On 9/19/2012 4:01 PM, David Mark wrote: > > >> Virtually everybody on the planet (save for you) is aware > >> of my contributions to jQuery > > > Um, no. You seem to hypothesize that you've been a driving force behind > > changes to the most popular library out there but there are very few, if > > any, who would agree with you. Sorry bro. :( > > >> Dojo > > > I recall reading your contributions to Dojo in the past, on their > > mailing list. Very amusing stuff. :) > > > Are we done yet? > > DM obviously understands js better than most. He posts links to > discussions, code, and other references in support of his statements yet > you reply with argumentum ad hominem. > Thanks for the kind words. I want to clarify one point though: lots of people know JS better than I do (I just tend to stick with what I know). Of course, history says I understand DOM scripting better than most (certainly better than anybody associated with the jQuery project). I ought to as I learned from Cornford's examples (which are sadly not available on the Web today). It's interesting that many of those examples were already fairly old in 2007. It's just that the bloggers of the Ajax era completely ignored such examples and set about reinventing the wheels, making all of the same old mistakes from the turn of the century (e.g. browser sniffing). They all but ignored (and often joked about) this newsgroup as some sort of "irrelevant" antique. Clearly the joke was on them as the answers they needed were here all along. :) In five years of "campaigning" here (and elsewhere), I'm sure I have influenced the development of a lot of "popular" libraries, though NIH syndrome prevents most of the authors from acknowledging that influence (they prefer to hurl insults like "troll"). Resig is one of the most disingenuous of the lot and has even expressed that he "hates" me. He won't even say my name (referring to me as "that guy" who "attacked" him while he was "feeding the trolls"). What a complete asshole. I'm quite happy to shred whatever is left of his reputation (he's been a laughingstock among serious JS developers for years). When you are a public figure, you have to expect public criticism. But clowns like him think they are somehow immune. Now, I know that their emotional reactions (or non-reactions as the case may be) are due to the controversial nature of my posts. As I stated back at the "beginning", I knew my somewhat caustic criticism would piss of the self-proclaimed rock stars of the Ajax era. However, as much of the information was old hat, I knew that the volume needed to be turned way up for anyone to hear me over the bloggers. Most (if not all) have gotten the message by now and the honest ones admit that. Their fans are clueless, so instead of congratulating me on my machinations moving browser scripting forward, they parrot their troll- spotting idols. :( > Do you believe your replies make > you look a winner? If so, he's even stupider than he sounds. But his psyche is his own problem; I just try to correct his near-constant flow of misinformation regarding jQuery, me, etc. He can spew his crap elsewhere, but it will *never* fly here. Nothing more pathetic than an anonymous jackass; it's as if he knows he is full of shit (and perhaps he does).
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Date | 2012-09-20 10:20 -0700 |
| Message-ID | <g1km58tbltbt3diiicf64v954cfa11vt8k@4ax.com> |
| In reply to | #16024 |
On Wed, 19 Sep 2012 17:09:49 -0700, "S.T." <anon@anon.com> wrote:
>On 9/19/2012 4:01 PM, David Mark wrote:
>
>> Virtually everybody on the planet (save for you) is aware
>> of my contributions to jQuery
>
>Um, no. You seem to hypothesize that you've been a driving force behind
>changes to the most popular library out there but there are very few, if
>any, who would agree with you. Sorry bro. :(
>
>> Dojo
>
>I recall reading your contributions to Dojo in the past, on their
>mailing list. Very amusing stuff. :)
>
>Are we done yet?
Could you point to a comp.lang.javascript post of yours where you
have been the slightest help at all? If not, go away.
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | David Mark <dmark.cinsoft@gmail.com> |
|---|---|
| Date | 2012-09-19 16:03 -0700 |
| Message-ID | <dc7c7d8c-0b99-452e-8c98-68d7b859e20a@k20g2000vbk.googlegroups.com> |
| In reply to | #16019 |
On Sep 19, 6:29 pm, "S.T." <a...@anon.com> wrote:
> On 9/19/2012 2:59 PM, David Mark wrote:
>
>
>
>
>
>
>
>
>
> > On Sep 19, 5:26 pm, "S.T." <a...@anon.com> wrote:
> >>> $(el).prop('value') == el.value;
> >>> $(el).attr('value') != el.value;
>
> >> The .val() method should be used for getting and setting value. Read the
> >> docs, man :)
Missed this comment before. I suggest you read the ten tons of
comments on the previously cited jQuery blog post related to the
"value" attribute/property (and not one mention of "val"). Perhaps the
docs are unclear on this matter. At the very least, the jQuery
community is (predictably) quite confused about all of this stuff (as
are you).
[toc] | [prev] | [next] | [standalone]
| From | David Mark <dmark.cinsoft@gmail.com> |
|---|---|
| Date | 2012-09-19 20:13 -0700 |
| Message-ID | <a3447822-4c50-43ac-ab19-79b25a044566@u19g2000yqo.googlegroups.com> |
| In reply to | #15986 |
On Sep 19, 1:57 am, David Mark <dmark.cins...@gmail.com> wrote:
> Here they "grow" again:
>
> http://stackoverflow.com/questions/10978870/jquery-prop-vs-attr-clari...
>
> "Using 1.7.2 and 1.8pre, whether you call .prop() or attr(), jQuery
> will internally always actually use .prop for:
>
> async, autofocus, autoplay, checked, controls, defer, disabled,
> hidden, loop,
> multiple, open, readonly, required, scoped, selected"
>
> This is what's known as an "active" project. Basically, they fiddle
> around with the logic behind the "simple" API forever. You never know
> what to expect from one version to the next. This is largely caused by
> flailing around trying to make the results match their confused
> expectations. I call it a "never finished" project.
>
> Though I didn't see this specific misstep coming, I knew from reading
> the recently mentioned "attr vs. prop" discussion (for lack of a
> better word) on StackOverflow (for lack of a better site) that they
> were confused about how to handle boolean properties/attributes. I
> just had no idea *how* confused. Here they've lumped all booleans (or
> at least the ones they've heard of) into a single group for special
> treatment (apparently starting with version 1.7.2).
>
> The above is a partial list of attributes (left out ismap for one)
> that are reflected as boolean properties. Two of them should stand out
> as fundamentally different from the rest. The "checked" and "selected"
> attributes are reflected by DOM properties with the "default" prefix
> (e.g. "defaultChecked"). The reason for this is simple: user actions
> may change the "checked" and "selected" properties and the DOM must
> keep track of the default values of these attributes (e.g. to reset
> forms). This is all spelled out very clearly in the DOM
> specifications, which predate jQuery by several years (so much for
> moving forward).
>
> So, once again, in trying to dumb down interfaces that they themselves
> don't understand, they've just made things more complicated for their
> users. If they'd have bothered to *read* this example (as opposed to
> just copying it into their repository for testing), they'd have
> understood the basic concept of "attr" vs. "prop":
>
> http://www.cinsoft.net/attributes.html
>
> To be specific, they've created collisions where the DOM (and my
> example) specifically avoided them.
>
> Right:
>
> $(el).prop('checked') == el.checked;
> $(el).attr('checked') == el.defaultChecked;
>
> Wrong:
>
> $(el).prop('checked') == el.checked;
> $(el).attr('checked') == el.checked;
>
One other clarification to avoid confusion. The concept of right and
wrong (and "attr" vs. "prop") throughout is based on jQuery's
(somewhat ambiguously) stated design goals, not the design of the
functions in the Attributes primer. This is one reason why it was so
absurd for Resig to copy my functions into his repository for testing.
As I told him (or one of his buddies) at the time, they were not
*exactly* what he needed to make sense out of his "attr" method
(though the code certainly contained all of the answers).
In short, as stated at the top of the primer, my example functions,
which were written with testing in mind, are interested in the
document's canonical form, therefore they specifically exclude user
data.
This is also true of the getAttribute and getAttributeProperty
functions found in My Library. They both do basically the same thing,
with one retrieving (normalized) string and the other more convenient
property values and always by *attribute* name (e.g. "for" not
"htmlFor", "class" not "className"). User data is always excluded as
there are other functions for retrieving that (similar jQuery's "val"
method). There's no ambiguity or overlap between these functions, each
has a specific job to do and none of them have been modified in years.
Good thing as such functions are the foundation of any DOM
manipulation library, so changing them has a very good chance of
disrupting not only higher-level functions within the library (e.g.
queries) but calling applications.
On the other hand, if your code needs to reference a property value by
property name, simply reference it:
var checked = el.checked;
var value = el.value;
var defaultValue = el.defaultValue;
Easy, reliable, compatible in virtually every browser ever made and no
function call overhead. You can't beat properties (unless you view
them through a "magic" prism like jQuery).
Don't see any need to provide an API function to do that. Might be
handy to add one to the E and Q prototypes, but that's left as a
(trivial) exercise.
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.javascript
csiph-web