From 0f3bad932b5d834a865348e63b9c47cfa920b58e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Wed, 26 Nov 2014 22:06:25 -0800 Subject: [PATCH] Fixed commenting on Facebook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed a regression in f87e7d0f71b9373dfa71384085370923317d80db that causes comments to be mangled as they are added on Facebook. Use deleteData() / insertData() instead of replaceData(). For some reason Facebook fails to react to the latter through its mutation observers. This change shouldn’t affect performance much because it’s still limited to just the one word. Fixes #105. --- content/frame.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/content/frame.js b/content/frame.js index bfb6c66..e1c1a6a 100644 --- a/content/frame.js +++ b/content/frame.js @@ -263,7 +263,8 @@ function SpliceTxn(outer, node, pos, len, repl) { */ this.doTransaction = this.redoTransaction = function() { this.orig = node.substringData(pos, len); - node.replaceData(pos, len, repl); + node.deleteData(pos, len); + node.insertData(pos, repl); this.shiftSelection(repl.length - len); }; @@ -271,7 +272,9 @@ function SpliceTxn(outer, node, pos, len, repl) { * Replaces the previously inserted substitution with the original string. */ this.undoTransaction = function() { - node.replaceData(pos, repl.length, this.orig); + //node.replaceData(pos, repl.length, this.orig); + node.deleteData(pos, repl.length); + node.insertData(pos, this.orig); this.shiftSelection(0); };