If you are looking purely from a technical javascript standpoint, I
understand.
But that's not what most people care about. The more important issue
is the big picture. Great javascript code is not the end goal for most
people - business decisions are. And if Google et al can build a
successful business using the strategy that you despise, by writing
code that you think is junk, then how can you blame others for doing
the same?
I don't blame anybody for anything. I just offer advice.
Obviously, using general-purpose libraries that are not up to your
standards on the public internet does not hold back these companies
from reaching their goals. If someone else comes in here asking about
If they were competent, perhaps they could set their goals higher. Or
maybe it wouldn't matter to the bottom line of a huge corporation.
What works for a huge corporation isn't necessarily going to translate
into success for Joe Webmaster.
which libraries to use to solve problems or to increase the
productivity of their team, they are probably thinking in the same
way. A perfect library that stands up to all criticisms would be
fantastic, but a well-documented, well-supported, well-tested library
that does most things right and can quickly reap rewards and help
Does what things right? I still contend that the library in question
is not exactly huge or all-encompassing. The time it takes to learn
it and deal with all of the issues from the 15% (or so) or users who
will not be able to use the resulting projects could be spent
learning. For instance, learning the difference between attributes
and DOM properties and how IE mixes up the two.
reach the business goals is better than nothing.
When you consider all the factors that most people are dealing with,
using libraries like jQuery makes an awful lot of sense. If you ONLY
Not for a public Website it doesn't. I thought Peter's comments
concerning expected rates of failure and the ramifications of those
failures was a good explanation of why it doesn't make sense at all
(unless the goal is abject failure.)
consider the pure coding quality of the underlying javascript, then
keeping your own set of "bullet-proof" libraries and reusable
Nothing is "bullet-proof." How you deal with the bullets that get
through is what is important. The author(s) of jQuery apparently deal
with them by shrugging.
functions might make the most sense. Most people, IMO, are interested
in the former. Many people in this group are interested in the latter.
I am very quickly losing interest in any sort of discussion regarding
jQuery, Prototype, Dojo, etc. Use whatever you want. It won't bother
me a bit. Just don't expect to encourage others to follow suit
without hearing dissenting opinions.
Thus, the conflict.
I would very much. Would you share it?
You would have been better off asking me that about twenty posts ago.
There are some situations where I've wanted to do it. It would be hard
to explain. But it's irrelevant.
Certainly. I don't need to do it. But I did need to create radio
buttons on the fly, so I ran into the problem. It isn't relegated to
nodes in the document, or even nodes with parents. The problem is
with IE's handling of the name attribute.
I haven't been able to find a solution. Have you?
I found a partial solution posted on some blog and had to spend some
time to perfect it for all cases. As I understand it, you are asking
about a specific case (changing types of elements in the document
tree) and I gave you several hints as to how to do that.
Unfortunately, you snipped them. Try googling for "IE setAttribute
type name outerHTML." But you still need to detect the problem before
you can implement the solution. Here is another hint:
Assuming el is an element object and has a getAttribute method, what
will this evaluate to in standards-based browsers?
el.getAttribute('style') && typeof(el.getAttribute('style')) ==
'object'
If it doesn't have a style attribute, it the first test will return
null and the second test is not evaluated. If it does have one, the
second test will return false. So in standards-based browsers, the
conjunction is always false.
Now consider current and past (broken) versions of IE which doesn't
know what attributes are (it thinks they are properties of the element
object.) Regardless of whether the element has a style attribute, it
has a style property which is an non-null object, so the first test
always passes. Obviously the second test is always evaluated for IE
and always true. Therefore, the conjunction is always true.
So there you have it. A boolean result that is guaranteed to tell you
when an implementation has broken attribute handling. Furthermore, it
does not harm future versions that will (hopefully) fix the problem.
Use that on an arbitrary element (I use the HTML element) during
feature detection and you only have to apply fixes for browsers that
are actually broken. The rest of them use get/setAttribute as normal.
And you should realize that this test does not directly indicate when
there will be a problem regarding the name and type attributes. That
is an inference (though a very good one) and you still need to detect
outerHTML support to work around those issues. You should also
realize at this point that this test does indicate specific problems
that can arise when confusing attributes and properties. For
instance, what do you suppose these will do in IE?
el.setAttribute('style', 'color:red');
el.setAttribute('onclick', 'alert("jQuery forgot to fix this");');
el.setAttribute('disabled', 'disabled'); // This too
el.setAttribute('checked', 'checked'); // And this
Now that you understand the problem, you can properly address it.
That's all the help I will give you on this. Perhaps if you had
posted the question first instead of running off at the mouth, I would
have helped you more.
My goal is to improve the tools that I and other developers use. I
Good.
have no emotional attachment to jQuery or any code. If real criticisms
You would seem in the minority among jQuery users.
and suggestions are raised, I want to address them. If they aren't
addressed by the jQuery team (I assume they will be), I'll consider
branching my own version of jQuery or something. I don't know.
Why expend effort to salvage an obvious derelict. Face it, you were
fooled into thinking you had a magic bullet, but it was really a time
bomb. The mad bombers who built it just shrugs off valid criticism.
The criticism will likely get more heated as more devices are
introduced with embedded browsers and they will likely continue to
chant "we don't care about anything but IE7, Opera 9, etc." Their
attitude does not indicate that they will switch gears to keep up with
the times and they are therefore doomed to end up an obscure footnote
in the history of browser scripting. Never mind the author's delusion
about remaining relevant for decades to come.
I haven't looked much at your toolkits, but why don't you concentrate
on building those up. It would make more sense to work with code you
are already familiar with. Attribute handling would seem a good
starting point.