in partnership with mediatemple

Ticket #793 (closed enhancement: fixed)

Opened 3 months ago

Last modified 2 months ago

$.object, adding toElement possibility to classes

Reported by: JanK Owned by:
Type: enhancement Priority: minor
Milestone: Mootools version 1.3 Component: Core
Keywords: Cc:

Description

I've seen support for obj.toElement in Prototype 1.6 changes, which allows el.inject(new Foo()); and .toElement is called on the instance of Foo to retrieve the element. I thought this could be a useful addition to MooTools.

$.object = function(obj, notrash, doc){
    if(obj.toElement) return $(obj.toElement(doc), notrash);
    return null;
};

Probably a check to avoid recursion should be added. This could be done by using $.element directly (no support for returning strings etc) or by checking the $type of the return value of obj.toElement which should not be 'object'.

Change History

Changed 2 months ago by digitarald

  • status changed from new to closed
  • resolution set to fixed

Added in r1467

Note: See TracTickets for help on using tickets.