Does jQuery.clone have side effects?

If $ dom is a jQuery element,

Is it possible to delete this line safely if anot used after?

var a = $dom.clone(true,true);

As the method clones dom, I think $dom.clone(false,false)it has no side effects . If you think that the method also cannot cause an error. I am more skeptical of the clone of events. I think that if the cloned element does not attach, it has no effects, but I'm not sure. Is there any event that can be propagated to a single dom event? (if so, then I'm not sure we can safely delete this line)

https://api.jquery.com/clone/

The purpose of the question is to determine if the absence is an @nosideeffectserror in determining externs .clone()here: https://github.com/google/closure-compiler/blob/master/contrib/externs/jquery-1.9.js#L405

+4
source share
1 answer

Whether the lack of this annotation is a mistake in terms of the Closure compiler definition of โ€œno side effectsโ€ is heavily dependent on Google. :-)

, jQuery 1.x .clone true, true jQuery, , , , jQuery, a: jQuery ( "", ) , jQuery, expando . - ; -: jQuery.

jQuery 2.x , , ( 2.x IE6 IE7, GC DOM/JS ).

+2

Source: https://habr.com/ru/post/1648019/


All Articles