Skip to content

Commit

Permalink
Merge pull request #1022 from yabwe/fix-performance
Browse files Browse the repository at this point in the history
Use innerHTML in Events.updateInput() function only once to improve performance
  • Loading branch information
nmielnik committed Mar 25, 2016
2 parents 73672d4 + cb0cdbf commit 2b26331
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/js/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,14 @@
}
// An event triggered which signifies that the user may have changed someting
// Look in our cache of input for the contenteditables to see if something changed
var index = target.getAttribute('medium-editor-index');
if (target.innerHTML !== this.contentCache[index]) {
var index = target.getAttribute('medium-editor-index'),
html = target.innerHTML;

if (html !== this.contentCache[index]) {
// The content has changed since the last time we checked, fire the event
this.triggerCustomEvent('editableInput', eventObj, target);
}
this.contentCache[index] = target.innerHTML;
this.contentCache[index] = html;
},

handleDocumentSelectionChange: function (event) {
Expand Down

0 comments on commit 2b26331

Please sign in to comment.