Skip to content

Commit 4fa785b

Browse files
committed
version 0.3.1: don't rerender unless we actually replaced some divs in no-line-break mode
1 parent 0da3b6c commit 4fa785b

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

angular-contenteditable.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@
66
var old_render;
77
elmt.bind('input', function(e) {
88
return scope.$apply(function() {
9-
var html, rerender;
9+
var html, html2, rerender;
1010
html = elmt.html();
1111
rerender = false;
1212
if (attrs.stripBr && attrs.stripBr !== "false") {
1313
html = html.replace(/<br>$/, '');
1414
}
1515
if (attrs.noLineBreaks && attrs.noLineBreaks !== "false") {
16-
html = html.replace(/<div>/g, '').replace(/<br>/g, '').replace(/<\/div>/g, '');
17-
rerender = true;
16+
html2 = html.replace(/<div>/g, '').replace(/<br>/g, '').replace(/<\/div>/g, '');
17+
if (html2 !== html) {
18+
rerender = true;
19+
html = html2;
20+
}
1821
}
1922
ngModel.$setViewValue(html);
2023
if (rerender) {

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-contenteditable",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"main": "angular-contenteditable.js",
55
"ignore": [
66
".*",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-contenteditable",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"description": "angular extensions",
55
"main": "angular-contenteditable.js",
66
"directories": {

src/contenteditable.coffee

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ angular.module('contenteditable', [])
1010
if attrs.stripBr && attrs.stripBr != "false"
1111
html = html.replace /<br>$/, ''
1212
if attrs.noLineBreaks && attrs.noLineBreaks != "false"
13-
html = html.replace(/<div>/g, '').replace(/<br>/g, '').replace(/<\/div>/g, '')
14-
rerender = true
13+
html2 = html.replace(/<div>/g, '').replace(/<br>/g, '').replace(/<\/div>/g, '')
14+
if html2 != html
15+
rerender = true
16+
html = html2
1517
ngModel.$setViewValue(html)
1618
ngModel.$render() if rerender
1719
if html == '' # the cursor if the contents is emty, so need to refocus

0 commit comments

Comments
 (0)