Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#9373 closed bug (wontfix)

domManip (append/prepend/etc.) RE-evaluates contained scripts

Reported by: rgibson@… Owned by:
Priority: low Milestone: 1.next
Component: manipulation Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:

Description

Using append (or another method implemented with domManip) to reposition an in-document element causes its scripts to be re-evaluated.

This is so because domManip passes all contained script elements to evalScript, which evaluates their code and removes the elements. I think it should skip evalScript for elements that are not disconnected or are otherwise known to have already been evaluated.

Change History (4)

comment:1 Changed 8 years ago by rgibson@…

comment:2 Changed 8 years ago by Rick Waldron

Component: unfiledmanipulation
Priority: undecidedlow
Resolution: wontfix
Status: newclosed

This is intended behaviour, if you don't need your scripts re-evaluted then i'd recommend separating your presentation from your logic.

comment:3 Changed 8 years ago by rgibson@…

If re-evaluation is intended, then why does evalScript remove elements from the DOM?

Also, why is this behavior not documented on the relevant Manipulation pages?

comment:4 Changed 7 years ago by rudibr@…

This have been bugging users for quite a few years now, at least a config option to turn on/off auto eval on dommanip would be nice.

Refactoring code to separate concerns , unfourtunately might not be an option in some cases. Im left with having to manually move out all the script tags every time I need a larger DOM manip (on content I cannot change).

Note: See TracTickets for help on using tickets.