- From: Mark S. Miller <erights@google.com>
- Date: Sat, 17 Sep 2011 15:04:42 -0700
- To: Anne van Kesteren <annevk@opera.com>
- Cc: public-script-coord@w3.org
- Message-ID: <CABHxS9gJZgShv+v153vDGKj8JK8uYWgAnRKfdXaDWoMd_H5-Xw@mail.gmail.com>
On Sat, Sep 17, 2011 at 2:57 PM, Anne van Kesteren <annevk@opera.com> wrote: > For the DOM we have this idea of having a method that can conveniently > create an element, set its attributes, event handlers, and child nodes. > However, to keep the method convenient some of those need to become optional > and therefore it requires some kind of overloading, which is where things > become problematic. > > Maybe there is a better design, but so far we have something like this: > > create(name) > create(name, attributes) > create(name, children) > create(name, attributes, children) > create(name, attributes, eventhandlers, children) > > name is a string. > > attributes is an object. > > eventhandlers is an object. > > children is either a Node or string, or an array of Nodes and strings. > > Examples: > > create('h1', 'Welcome!') > create('button', {name: 'command', value: 'search'}, {onclick: teehee}, > 'Search') > create('p', {title: 'hi'}, [node, node2]) > > The problem is however that arrays and objects are not really > distinguishable unless you do "evil things". > > Anyone with ideas? > Array.isArray <http://es5.github.com/#x15.4.3.2> is not evil. If for some reason that is unsuitable, there are some ideas at < http://wiki.ecmascript.org/doku.php?id=conventions:isarraylike>. Though like I say at the note at the top, I no longer believe it is practical to attempt to standardize an isArrayLine based on current practice. > > > -- > Anne van Kesteren > http://annevankesteren.nl/ > > -- Cheers, --MarkM
Received on Saturday, 17 September 2011 22:05:09 UTC