Skip to content

Instantly share code, notes, and snippets.

@josephg
Created February 10, 2012 05:03
Show Gist options
  • Save josephg/1786829 to your computer and use it in GitHub Desktop.
Save josephg/1786829 to your computer and use it in GitHub Desktop.
Mutation Observer record log for paste operation
Given a contenteditable div containing this html:
<p>a paragraph with some <b>bold text</b> and <i>italics text</i></p>
I copy+pasted a duplicate of the 'h' character at the end of 'paragraph'. This is the mutation records:
Got 35 mutation record(s)
added text node with 'a paragraphh'
changed text from 'a paragraph with some ' to ' with some '
added element <p></p>
removed text node with ' with some '
added text node with ' with some '
removed element <b>bold text</b>
added element <b>bold text</b>
removed text node with ' and '
added text node with ' and '
removed element <i>italics text</i>
added element <i>italics text</i>
changed text from ' with some ' to ' with some '
changed text from 'ith some ' to ' with some '
changed text from 'with some ' to ' with some '
added element <span style="color: rgb(0, 0, 0); font-family: Times; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; display: inline !important; float: none; "></span>
removed text node with ''
added text node with ''
removed element <span style="color: rgb(0, 0, 0); font-family: Times; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; display: inline !important; float: none; "></span>
added element <br>
changed text from 'h' to ''
removed text node with ''
removed element <br>
changed text from 'a paragraph' to 'a paragraphh'
changed text from 'a paragraph' to 'a paragraphh'
removed text node with ' with some '
removed element <b>bold text</b>
removed text node with ' and '
removed element <i>italics text</i>
added element <br>
removed element <br>
removed element <p></p>
added text node with ' with some '
added element <b>bold text</b>
added text node with ' and '
added element <i>italics text</i>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment