David said:
Garrett said:
David said:
Garrett Smith wrote:
David Mark wrote:
Garrett Smith wrote:
Thomas 'PointedEars' Lahn wrote:
David Mark wrote:
If you build a new library, it will now "work" for all but IE8
standards mode. But I don't want it to work like that, so soon it
will fail for all. Always set the type attribute/property _first_
(or
use a wrapper that does that for you).
And that wrapper is API.createElementWithAttributes:-
You can't be serious. What's wrong with `API.createElement', the
`API' aside (see below)?
[...]
There is a similar issue with the name attribute/property in that it
must be set after appending the element if it is to show up in the
appropriate DOM collection (e.g. document.forms, document.images,
window.frames). That is an issue best handled with a wrapper that
creates _and_ appends an element. Call it
createAndAppendElementWithAttributes perhaps?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
No, thanks.
Generalized element builders.
There are too many edge cases support.
That's meaningless.
There are problems with nodes
that can't accept other nodes, special handling for certain attributes
(cellPadding, name).
There are no issues if you have competently written wrappers. Of
course, that lets out... virtually everyone. As for problems of nodes
not accepting other nodes, that's inherent to the underlying DOM
interface, so is irrelevant for a wrapper (unless it claims to support
non-standard behavior).
What about appending to a SELECT?
What about it?!
It is obviously inconsistent. The appended option's `selected` may be
null, string, or boolean (true OR false).
Oh, forget that bullshit. That property doesn't matter until you append
the thing to a document. Host objects 101. Don't try to do stupid things.
DOn't try stupid things? Like what? Append an OPTION to a SELECT and
then append the SELECT to the DOM, but expect something related to the
option being selected? Nope, I have a different approach for SELECTs.
Here's another stupid idea: A wrapper for DOM attributes.
I don't follow that, even if you mean adding an option to a select. The
way to address the "issue" is in a function that finds the selected option.
A function createAndAppendElementWithAttributes would seem to be capable
of creating and appending an element with attributes. It should also be
reasonably expected to be consistent across browsers.
You don't even need to know about the problems with adding an OPTION to
a SELECT to recognize the obviousness of that.
So? You don't know how to fix that? See the wrapper posted in this
thread.
The solution I am familiar with is using MS createElement nonstandard
extension.
That approach is specified to throw errors, and so if it is used, then
it must be feature tested and the feature test would involve try-catch.
Examples of what? That anchors don't show up in the anchors or links
collections if you name them prematurely? Same for forms, iframes, etc.
It's an old issue and easily dealt with in a wrapper.
About what? The unit tests (and don't start with semantics again?) No,
not really as it was sort of missing the point.
No, that too, though. I commented on the long section of statements you
refer to as a "unit test" in your viewport function.
So nothing. It's there. This stuff should not be an issue in 2010 for
a browser that came out in 1999. The whole idea is beyond belief.
I do not keep tabs on when you write things.
Looks like your reply ran aground here. (?)
Creating nodes can work for specific tasks such as above, but for
general purpose, it is unneeded.
Or parser or anything that needs to canonicalize the document. Use your
imagination.
Speculate on a need that does not exist? Never.
Work the other way.
Create abstractions as they're needed. Organize the abstractions to
allow for effective reuse.
Test the abstractions. When something doesn't work, the test can be
added to the suite. When the abstration gets refactored, then the tests
can reflect that.
Adding OPTION to a SELECT is very generic, but probably can work in
almost any normal context.
Creating a specific widget (UserPanel) is going to be more specific. In
a specific case, for a higher level widget, the nodes/html for the
widget can be generated in a self-contained function.
Almost nobody does, but...
Nope.
Which is something you can build on top of the low-level functions. And
not just for an editor either. Are you familiar with things like the
Dijit (ecch) parser?
Feel free to enlighten me.
My experiences with Dojo based applications is that they tend to be slow
to load. Well I've only worked on two applications that used Dojo.
Other applications that use dojo that I interviewed for, they complained
about slow performance.
[...]
Dammit. Your quoting is fucking up here again. No way this is my
fault. I used GG for years and never hard this problem.
?
I wasn't.
Why would you have to remember the name of that method?
No I am not. You are barking up the wrong tree.
YOu wrote "You return early if the element is not in the document." That
is wrong. Please do look at that one line of code.
It is not a tree.
Of course not. It has to do with code design, not clarity. Returning
early like that is bullshit.
Oh really? It is "bullshit" to return early? Who taught you that? Or
better yet, why did you believe it?
Restructure the design so that the caller
doesn't call in the first place in that circumstance. If you are
worried about public API calls, you don't want those to fail silently
either.
What caller and what circumstance?
The caller of that method calls it so that the calendar can be created.
If the calendar is already created, then the method exits.
Bullshit and no time for semantic arguments. Thanks anyway.
Apparently the code comment did *not* help. So it is down to an English
problem. What meaning do you get from: "If the element is not null, exit."
Confusion is not the issue either.
Apparently it was.
Again, the quoting is off. The problem is in your set.
And why not? They don't have to have knowledge of it. It could be
optional with the default the same as it is now. Context is everything
with this stuff. You can't decide what is best for all apps.
The job of the API is to define a public interface. More options means
more complexity, more bloat, longer methods, harder to read, more bugs,
more maintenance time.
I asked you to explain yourself.
You misinterpreted that one line of code. It seems likely that you're
misunderstanding other things about that code.
Don't blame me for your misunderstanding. Don't call bullshit and say
that I'm not thinking.
What you repeated is correct, but there seems to
be some design concepts that aren't registering with you. Asking where
I am "getting this" isn't likely to bear fruit.
What I repeated was what you stated, but in question form. I can't make
sense of what you're saying here, or why.
So is writing a calendar widget, yet they both have practical
applications as well.
A Calendar widget is not limited to learning about browser quirks.
Or anything else that creates elements.
Nope. Because sometimes, innerHTML might be a better option. Sometimes
Array.prototype.join or Array.prototype.push would be good options for
that. In some cases, not all cases, the code might have a browser quirk
to deal with. In other cases, another browser quirk might appear.
What sorts of quirks? Creating a table with cellPadding, creating a
named anchor.
It depends on the author(s),
context, scope of the project, etc. Certainly an editor (which seems to
be the centerpiece of every widget library) is the quintessential example.
If the attribute wrapper is needed for an Editor then limit it to that.