If you have the references for the node you want to adopt it will be almost
the same thing as set/get html.

@atwork8, just testing, is "Please, shut the fuck up" rude for you?




--
Fábio Miranda Costa
Solucione Sistemas
Front-End Engineer
http://meiocodigo.com


On Thu, Aug 27, 2009 at 6:07 PM, atwork8 <[email protected]> wrote:

>
> If I came across as being rude it wasn't intended, apologies. I felt I
> was clear on what the problem was and even provided my current
> solution. The first answer I received seemed to ignore this and
> provide a solution that was exactly the opposite of what I had asked,
> hence I asked Fabio to read the problem again (and used the word
> "Please").
>
> In the simple scenario of wrapping an element's html, are there any
> performance gains using adopt over get/set html?
>
> Cheers
>
> On Aug 27, 9:33 pm, nwhite <[email protected]> wrote:
> > > One would ask the question "Why don’t you just output the wrapper div
> in
> > > your html?"
> >
> > Sometimes you don't have full control over the html generation.
> >
> > @atwork8 I thought your tone was a bit rude especially when your asking
> for
> > help. A bit of diplomacy will get you farther.
> >
> > I would use adopt since it will take multiple elements.
> >
> > new Element('div',{'id :
> > 'wrapper'}).adopt($(document.body).getChildren()).inject(document.body);
> >
> > > -----Original Message-----
> > > From: ksamdev [mailto:[email protected]]
> > > Sent: Friday, 28 August 2009 1:00 AM
> > > To: MooTools Users
> > > Subject: [Moo] Re: wrap element's html
> >
> > > @atwork8
> >
> > > No benefits. The result would be the same except that work is done
> > > with DOM objects directly if you do things the way I proposed which I
> > > find very clear and always tend to work with. It is simply conceptual
> > > difference. Anyway, I guess at the end browser will rearrange DOM tree
> > > and do the job in background putting all children into new DIV.
> > > Besides, I guess, it will have to parse new HTML of document.body that
> > > would take some time. Thus, presumably, It is faster to work with DOM
> > > Tree.
> >
> > > On Aug 27, 7:36 am, atwork8 <[email protected]> wrote:
> > > > @ksamdev - what are the benefits of doing it that way over what I had
> > > > originally posted?
> >
> > > > var elBody = $(document.body);
> > > > elBody.set('html', '<div id="wrapper">' + elBody.get('html') + '</
> > > > div>');
> >
> > > > On Aug 27, 1:27 pm, ksamdev <[email protected]> wrote:
> >
> > > > > ok. I see your point. Then do something like:
> >
> > > > > var _div = new Element( 'div');
> > > > > var _body = $( document.body);
> > > > > _body.getChildren().each( function( _item) { _div.grab( _item); });
> > > > > _body.adopt( _div);
> >
> > > > > On Aug 27, 7:22 am, atwork8 <[email protected]> wrote:
> >
> > > > > > @ksamdev - Could you please read the problem. The results are
> > > > > > completely different. The solution I've provided generates this:
> >
> > > > > > <body><div id="wrapper">body's html</div></body>
> >
> > > > > > Fabio's generates:
> >
> > > > > > <div id="wrapper"><body>body's html</body></div>
> >
> >
>

Reply via email to