We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
trim
1 parent 4ef89af commit 413eaa0Copy full SHA for 413eaa0
lib/dom-to-react.js
@@ -24,6 +24,8 @@ function domToReact(nodes, options) {
24
var replaceElement;
25
var props;
26
var children;
27
+ var data;
28
+ var trim = options.trim;
29
30
for (var i = 0, len = nodes.length; i < len; i++) {
31
node = nodes[i];
@@ -46,7 +48,15 @@ function domToReact(nodes, options) {
46
48
}
47
49
50
if (node.type === 'text') {
- result.push(node.data);
51
+ // if trim option is enabled, skip whitespace text nodes
52
+ if (trim) {
53
+ data = node.data.trim();
54
+ if (data) {
55
+ result.push(node.data);
56
+ }
57
+ } else {
58
59
60
continue;
61
62
0 commit comments