projects
/
roojs1
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix #8042 - clean up empty tags
[roojs1]
/
Roo
/
htmleditor
/
FilterEmpty.js
diff --git
a/Roo/htmleditor/FilterEmpty.js
b/Roo/htmleditor/FilterEmpty.js
index
642f992
..
383d5aa
100644
(file)
--- a/
Roo/htmleditor/FilterEmpty.js
+++ b/
Roo/htmleditor/FilterEmpty.js
@@
-1,6
+1,6
@@
/**
* @class Roo.htmleditor.FilterEmpty
/**
* @class Roo.htmleditor.FilterEmpty
- * filter empty elements
(normally <B> on paste)
+ * filter empty elements
* @constructor
* Run a new Empty Filter
* @param {Object} config Configuration options
* @constructor
* Run a new Empty Filter
* @param {Object} config Configuration options
@@
-12,22
+12,32
@@
Roo.htmleditor.FilterEmpty = function(cfg)
this.walk(cfg.node);
}
this.walk(cfg.node);
}
-Roo.extend(Roo.htmleditor.Filter
Span
, Roo.htmleditor.FilterBlack,
+Roo.extend(Roo.htmleditor.Filter
Empty
, Roo.htmleditor.FilterBlack,
{
{
- tag :
'B'
,
+ tag :
true
,
replaceTag : function(node)
{
replaceTag : function(node)
{
- if (node.innerHTML.trim() != '') {
- return true;
+ // start from leaf node
+ if(node.hasChildNodes()) {
+ this.walk(node);
}
}
- if (node.attributes && node.attributes.length > 0) {
- return true; // walk if there are any.
+
+ // only filter empty leaf element with certain tags
+ if(
+ ['B', 'I', 'U', 'S'].indexOf(node.tagName) < 0
+ ||
+ node.attributes && node.attributes.length > 0
+ ||
+ node.hasChildNodes()
+ ) {
+ return false; // don't walk
}
}
+
Roo.htmleditor.FilterBlack.prototype.replaceTag.call(this, node);
Roo.htmleditor.FilterBlack.prototype.replaceTag.call(this, node);
- return false;
+ return false;
// don't walk
}
}