Re: Derive DOM element tamings from specification data. (issue 6741065)

28 views
Skip to first unread message

jas...@gmail.com

unread,
Nov 9, 2012, 5:35:32 PM11/9/12
to kpreid.sw...@gmail.com, google-ca...@googlegroups.com, re...@codereview-hr.appspotmail.com
For fun I ran a check on Chrome using these html4 and html5 defs.

xxx.forEach(function(x) {
var el = document.createElement(x.key);
var cand = Object.prototype.toString.call(el);
if (cand.indexOf(x.interface) == -1) {
print(x.key + " => " + cand + ", not " + x.interface);
}
});

From html4:

APPLET => [object HTMLAppletElement], not HTMLElement
BASEFONT => [object HTMLBaseFontElement], not HTMLElement
DIR => [object HTMLDirectoryElement], not HTMLElement
FONT => [object HTMLFontElement], not HTMLElement
FRAME => [object HTMLFrameElement], not HTMLElement
FRAMESET => [object HTMLFrameSetElement], not HTMLElement
TD => [object HTMLTableCellElement], not HTMLTableDataCellElement
TH => [object HTMLTableCellElement], not HTMLTableHeaderCellElement

From html5:
COMMAND => [object HTMLElement], not HTMLCommandElement
DATA => [object HTMLUnknownElement], not HTMLElement
DIALOG => [object HTMLUnknownElement], not HTMLDialogElement
TIME => [object HTMLUnknownElement], not HTMLTimeElement

None of these seem significant differences -- they're essentially ways
in which Chrome varies from the html5 spec.

https://codereview.appspot.com/6741065/

jas...@gmail.com

unread,
Nov 9, 2012, 6:08:54 PM11/9/12
to kpreid.sw...@gmail.com, google-ca...@googlegroups.com, re...@codereview-hr.appspotmail.com

https://codereview.appspot.com/6741065/diff/11001/src/com/google/caja/plugin/domado.js
File src/com/google/caja/plugin/domado.js (right):

https://codereview.appspot.com/6741065/diff/11001/src/com/google/caja/plugin/domado.js#newcode5900
src/com/google/caja/plugin/domado.js:5900: 'HTMLTableCellElement',
So should this become HTMLTableDataCell now? How does allDomNodeClasses
interact with the element defs?

https://codereview.appspot.com/6741065/

kpreid.sw...@gmail.com

unread,
Nov 12, 2012, 3:29:10 PM11/12/12
to jas...@gmail.com, google-ca...@googlegroups.com, re...@codereview-hr.appspotmail.com
New snapshot.
On 2012/11/09 23:08:54, Jasvir wrote:
> So should this become HTMLTableDataCell now?

No. HTMLTableCellElement is the superclass of HTMLTableDataCellElement
and HTMLTableHeaderCellElement.

> How does allDomNodeClasses interact with the element defs?

This *was* a *complete* list of standard classes (it is no longer
complete due to HTML5 etc.); the ones in this list but not otherwise
implemented are made into aliases for HTMLElement.

It occurs to me that we could instead generate this list from all
interfaces mentioned in the schema. Comparison of the results this would
have pointed out a few mistakes in the schema data and Domado; after
fixing those, the only difference that results is that we would lose
HTMLIsIndexElement and HTMLNavElement. Both are not specified by HTML5.

Therefore, I have gone ahead and done so; this list is now gone.

https://codereview.appspot.com/6741065/

jas...@gmail.com

unread,
Nov 13, 2012, 12:58:08 PM11/13/12
to kpreid.sw...@gmail.com, google-ca...@googlegroups.com, re...@codereview-hr.appspotmail.com
With the caveat to doublecheck the use of gOPN, LGTM


https://codereview.appspot.com/6741065/diff/14001/src/com/google/caja/plugin/html-schema.js
File src/com/google/caja/plugin/html-schema.js (right):

https://codereview.appspot.com/6741065/diff/14001/src/com/google/caja/plugin/html-schema.js#newcode176
src/com/google/caja/plugin/html-schema.js:176:
table[ELEMENT_DOM_INTERFACES[el]] = true;
Note - it's safe to use object as a dictionary here since
ELEMENT_DOM_INTERFACES is known not to contain elements like toString
and valueOf.

https://codereview.appspot.com/6741065/diff/14001/src/com/google/caja/plugin/html-schema.js#newcode179
src/com/google/caja/plugin/html-schema.js:179: scriptInterfacesCache =
cajaVM.def(Object.getOwnPropertyNames(table));
Double check - this file gets run cajoled (in which case
Object.getOwnPropertyNames is shimmed in) or in SES in which case gOPN
is browser provided).

https://codereview.appspot.com/6741065/

kpreid.sw...@gmail.com

unread,
Nov 13, 2012, 1:14:09 PM11/13/12
to jas...@gmail.com, google-ca...@googlegroups.com, re...@codereview-hr.appspotmail.com

https://codereview.appspot.com/6741065/diff/14001/src/com/google/caja/plugin/html-schema.js
File src/com/google/caja/plugin/html-schema.js (right):

https://codereview.appspot.com/6741065/diff/14001/src/com/google/caja/plugin/html-schema.js#newcode176
src/com/google/caja/plugin/html-schema.js:176:
table[ELEMENT_DOM_INTERFACES[el]] = true;
On 2012/11/13 17:58:08, Jasvir wrote:
> Note - it's safe to use object as a dictionary here since
> ELEMENT_DOM_INTERFACES is known not to contain elements
> like toString and valueOf.

I'm not sure which object (ELEMENT_DOM_INTERFACES or table) you're
referring to here. Either way, this is safe even if that is not the
case: we iterate over own properties of ELEMENT_DOM_INTERFACES, and the
only thing we ever do with 'table' is get its own properties. This is
just a deduplicator.

https://codereview.appspot.com/6741065/diff/14001/src/com/google/caja/plugin/html-schema.js#newcode179
src/com/google/caja/plugin/html-schema.js:179: scriptInterfacesCache =
cajaVM.def(Object.getOwnPropertyNames(table));
On 2012/11/13 17:58:08, Jasvir wrote:
> Double check - this file gets run cajoled (in which case
> Object.getOwnPropertyNames is shimmed in) or in SES
> in which case gOPN is browser provided).

Yes. This is part of the bundle which includes Domado. Note that it uses
cajaVM.def which only exists in Caja environments, regardless of browser
ES5 support.

https://codereview.appspot.com/6741065/
Reply all
Reply to author
Forward
0 new messages