Skip to content

Commit 7b5af29

Browse files
committed
Remove content.normalizeSpaces()
1 parent 958cd3d commit 7b5af29

File tree

3 files changed

+13
-29
lines changed

3 files changed

+13
-29
lines changed

src/content.js

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ var content = (function() {
1010
var zeroWidthNonBreakingSpace = /\uFEFF/g;
1111

1212
return {
13+
14+
/**
15+
* Clean up the Html.
16+
*/
17+
tidyHtml: function(element) {
18+
this.normalizeTags(element);
19+
},
20+
21+
1322
/**
1423
* Remove empty tags and merge consecutive tags (they must have the same
1524
* attributes).
@@ -164,27 +173,6 @@ var content = (function() {
164173
}
165174
},
166175

167-
/**
168-
* Convert the first and last space to a non breaking space charcter to
169-
* prevent visual collapse by some browser.
170-
*
171-
* @method normalizeSpaces
172-
* @param {HTMLElement} element The element to process.
173-
*/
174-
normalizeSpaces: function(element) {
175-
var nonBreakingSpace = '\u00A0';
176-
177-
if (!element) return;
178-
179-
if (element.nodeType === nodeType.textNode) {
180-
element.nodeValue = element.nodeValue.replace(/^(\s)/, nonBreakingSpace).replace(/(\s)$/, nonBreakingSpace);
181-
}
182-
else {
183-
this.normalizeSpaces(element.firstChild);
184-
this.normalizeSpaces(element.lastChild);
185-
}
186-
},
187-
188176
/**
189177
* Get all tags that start or end inside the range
190178
*/

src/core.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ Editable.prototype.enable = function($elem, normalize) {
141141

142142
if (normalize) {
143143
$elem.each(function(index, el) {
144-
content.normalizeTags(el);
145-
content.normalizeSpaces(el);
144+
content.tidyHtml(el);
146145
});
147146
}
148147

src/default-behavior.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,8 @@ var createDefaultBehavior = function(editable) {
102102
}
103103
element.appendChild(after);
104104

105-
content.normalizeTags(newNode);
106-
content.normalizeSpaces(newNode);
107-
content.normalizeTags(element);
108-
content.normalizeSpaces(element);
105+
content.tidyHtml(newNode);
106+
content.tidyHtml(element);
109107
element.focus();
110108
},
111109

@@ -136,8 +134,7 @@ var createDefaultBehavior = function(editable) {
136134
merger.parentNode.removeChild(merger);
137135

138136
cursor.save();
139-
content.normalizeTags(container);
140-
content.normalizeSpaces(container);
137+
content.tidyHtml(container);
141138
cursor.restore();
142139
cursor.setVisibleSelection();
143140
},

0 commit comments

Comments
 (0)