As per a recent discussion http://groups.google.com/group/prototype-core/browse_thread/thread/16d0517ecc605a00 I have made a few notes regarding a potential semantics of an "element wrapper" implementation : )
== Notes: - The notion of `NodeWrapper` is used to refer to such "element wrapper". - `$W` function is assumed to accept an "id" string and return a new `NodeWrapper` instance "over an element" with that "id". - Each statement is followed by a brief example (for clarity). - Naming conventions are a subject of change. == Semantics: 1) NodeWrapper always exposes a public `source` property, which is a reference to a wrapped element: $W('foo').source; // An actual element with id="foo" 2) NodeWrapper's mutator methods always return a reference to a NodeWrapper they act upon: $W('foo').addClassName('foo'); // NodeWrapper around an element with id="foo" 3) NodeWrapper's methods that act upon an element other than the original one, return that element's NodeWrapper: $W('foo').wrap('div', { className: 'bar' }); // NodeWrapper around a newly created `div` element with class="bar" 4) NodeWrapper always exposes public `get`/`set` methods which are accessor/mutator methods for properties of a wrapped element: $W('foo').get('innerHTML'); // returns a value of `innerHTML` property of an element with id="foo" $W('foo').set('tabIndex', 1); // sets `tabIndex` property of an element with id="foo" to 1 5) `Element`, when called as a constructor, always returns a NodeWrapper for a newly created element: new Element('div', { className: 'foo' }); // a wrapper for a newly created <div class="foo"></div> Any comments/objections are welcomed ; ) -- kangax --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---