Page MenuHomePhabricator

Code generation of HTML*Element DOM classes
Closed, ResolvedPublic

Description

Domino uses dynamic class generation for generating WebIDL HTML*Element classes. However, PHP doesn't support that in quite the same way. So, we need to figure out a way of generating these classes.

Some options:

  1. Generate PHP code from the WebIDL (T271724) descriptions. See how the jsdom DOM library does this: https://github.com/jsdom/webidl2js#readme and https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/nodes/HTMLAnchorElement.webidl . We'd need to write a webidl2php and likely use our wikipeg parsing library to parse the WebIDL.
  2. Simply translate the data tables used by domino to PHP (ie, using js2php), and port the domino class generation code, except do it at build time not at run time.

In most cases where Dodo is used as a replacement for PHP's libxml binding, these classes aren't needed (since PHP doesn't define the HTML* subclasses). This code is mostly used for compliance and passing spec tests. (There are corner cases where the HTML subclasses define specific attribute accessors (etc) which might not be obviously in use -- this was a concern when Parsoid was ported to PHP, but these have probably all been replaced by explicit getAttribute calls by now.) As such this task needn't be a blocker to adoption of Dodo in Parsoid and is lower priority.