0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 07:13:08 -05:00

Check for queued events before disconnecting mutation observer

Fixes #252
This commit is contained in:
Neil Jenkins 2016-12-12 10:35:14 +11:00
parent 3d8cd62edb
commit c1c63478f0
3 changed files with 22 additions and 14 deletions

View file

@ -2626,16 +2626,20 @@ proto.getRoot = function () {
};
proto.modifyDocument = function ( modificationCallback ) {
this._ignoreAllChanges = true;
if ( this._mutation ) {
this._mutation.disconnect();
var mutation = this._mutation;
if ( mutation ) {
if ( mutation.takeRecords().length ) {
this._docWasChanged();
}
mutation.disconnect();
}
this._ignoreAllChanges = true;
modificationCallback();
this._ignoreAllChanges = false;
if ( this._mutation ) {
this._mutation.observe( this._root, {
if ( mutation ) {
mutation.observe( this._root, {
childList: true,
attributes: true,
characterData: true,

File diff suppressed because one or more lines are too long

View file

@ -214,16 +214,20 @@ proto.getRoot = function () {
};
proto.modifyDocument = function ( modificationCallback ) {
this._ignoreAllChanges = true;
if ( this._mutation ) {
this._mutation.disconnect();
var mutation = this._mutation;
if ( mutation ) {
if ( mutation.takeRecords().length ) {
this._docWasChanged();
}
mutation.disconnect();
}
this._ignoreAllChanges = true;
modificationCallback();
this._ignoreAllChanges = false;
if ( this._mutation ) {
this._mutation.observe( this._root, {
if ( mutation ) {
mutation.observe( this._root, {
childList: true,
attributes: true,
characterData: true,