use setTimeout rather than MutationObserver #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
MutationObserver may fire multiple times for very large pastes. For example, if you go to this page
http://www.2ality.com/2015/02/es6-classes-final.html
Press ctrl+a, ctrl+c and then paste into here:
http://requirebin.com/?gist=TooTallNate/789b7e9cefb8be3f8254
You will see that the domPaste callback is called multiple times, whereas only one paste event is fired.
@TooTallNate
EDIT: I should point out i've only tested this in Chrome. Not sure about other browsers.
EDIT2: Firefox does not seem to have the issue. Safari just plain chokes if you try to do such a crazy paste, so it may or may not have the issue with a paste of some intermediate level of insanity.
EDIT3: The issue appears to be connected to the presence of
<iframe>
's in the paste. If you remove the iframe's from that page, the issue disappears - though it doesn't seem to get one additional event for each frame, so it's unclear to me exactly what is happening.