Differences in Specifications

T

TastyWheat

I've come upon two sources for DOM specification and I'm wondering if
one is outdated or a different implementation or what. My first source
is from W3C (using table as an example):

http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-64060425

My other source is from Sun Microsystems:

http://java.sun.com/j2se/1.5.0/docs/guide/plugin/dom/org/w3c/dom/html/HTMLTableElement.html

Obviously you can see some differences like W3C says HTMLTableElement
has a read/write attribute for cellPadding. Sun says that you need to
read and set this property using getCellPadding() and setCellPadding()
(respectively). Also, I've seen different uses for creating objects
such as:

document.createElement("option")
VS.
new Option(...,...)

So is one of these more correct than the other? Is there a problem
when mixing these two standards?
 
R

Randy Webb

TastyWheat said the following on 10/18/2006 3:34 PM:
I've come upon two sources for DOM specification and I'm wondering if
one is outdated or a different implementation or what. My first source
is from W3C (using table as an example):

http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-64060425

My other source is from Sun Microsystems:

http://java.sun.com/j2se/1.5.0/docs/guide/plugin/dom/org/w3c/dom/html/HTMLTableElement.html

One is the W3C's Recommended Standard, the other is the documentation
for the Mozilla family browsers.
Obviously you can see some differences like W3C says HTMLTableElement
has a read/write attribute for cellPadding. Sun says that you need to
read and set this property using getCellPadding() and setCellPadding()
(respectively).

The browser's documentation is a better resource than the W3C's. One
states the way things should work, the other states the way things
really work.
Also, I've seen different uses for creating objects such as:

document.createElement("option")
VS.
new Option(...,...)

So is one of these more correct than the other? Is there a problem
when mixing these two standards?

Feature detect and use the one that is supported and does what you want
it to do. The point: There is no simple answer to that specific question.
 
M

Martin Honnen

TastyWheat said:
I've come upon two sources for DOM specification and I'm wondering if
one is outdated or a different implementation or what. My first source
is from W3C (using table as an example):

http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-64060425

That is the W3C specification and defines interfaces in the
specification using an idl, interface definition language. If you read
the complete specification you will also find bindings for particular
languages, i.e. Java and ECMAScript (which means JavaScript, JScript).

That is part of the Java 1.5 documentation so it does not apply to
JavaScript/ECMAScript, only to Java. If you compare that documentation
to the Java binding the W3C specification defines you should see they
are the same.

So for this JavaScript group the W3C specification and its ECMAScript
binding are relevant. If you want to program in Java then the W3C
specification and its Java binding are relevant, and of course any
documentation for the Java implementation you use.
 
T

TastyWheat

Martin said:
That is part of the Java 1.5 documentation so it does not apply to
JavaScript/ECMAScript, only to Java. If you compare that documentation
to the Java binding the W3C specification defines you should see they
are the same.

Okay, so that doesn't apply to JavaScript.

As for the other thing, the initialization, that's browser dependent?
So if both of those methods are supported I can mix and match? What if
neither of those are supported? Do I have to resort to the dreaded
document.write(...)?
 
M

Martin Honnen

TastyWheat said:
As for the other thing, the initialization, that's browser dependent?

What other thing?
new Option() versus document.createElement('option')?
That is part of the historical development of browser (DOM) APIs,
somewhere after the beginning (around Netscape 3) you could not
dynamically create many elements but only a few so those designing the
APIs chose a unique "constructor" for each element (e.g. new Option()
for creating option elements) or object (e.g. new Image() for image
objects for preloading). Later on with browser progress and the
standardization of the W3C DOM a move was made to allow you to create
any element and thus one factory method document.createElement was
introduced allowing you to create any element with the factory method.
At least in theory of the W3C DOM API which was standardized while
browser developers battled and introduced features. For instance IE 4
already had document.createElement but could nevertheless create only a
few elements (e.g. option) with that method.

Nowadays whether you would use new Option() or
document.createElement('option') depends on your browser targets, if
your document should allow users of e.g. Netscape 4 to add options
dynamically then you need to use new Option() but if you are building
stuff that does not work with Netscape 4 anyway then you can as well use
document.createElement to be consistent.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top