开发者

is it possible to tell if DOM was modified, and which part?

开发者 https://www.devze.com 2022-12-23 20:50 出处:网络
Are there any practical ways to tell what part of the DOM was modified if you know that it will be modified?

Are there any practical ways to tell what part of the DOM was modified if you know that it will be modified?

I am writing a plugin that will be running along wit开发者_如何学编程h javascript that i did not write. an event will be triggered before DOM is modified, and one event will be triggered after the modification. It is my job to decide what was changed. is this possible, and if so what is the least horrible way to do this?


Depending on the browser support you need, you may be able to use DOM mutation events.


A possibility, if you know what aspect of the DOM elements are to be modified, is to store the value of that attribute in a .data() node for each element on page load, then compare after the script is run.


You could also do a hash of the page text (e.g. complete source string) and compare it (on change) to current hash.


With jquery you could trigger :animated filter to search the elements being animated, i don't know if you will have so much delay between these kind of events, but if main trigger on initial transform is triggered just when transformation is initiated you could try to catch :animated element and capture initial state before ending animation, then on end capture state and compare, its only a hint i don't have any demonstration or way to reproduce your working environment but i hope this guideline could give you a idea.


This is not possible in any practical manner

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号