File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -183,6 +183,8 @@ exports.extractContent = function (el, asFragment) {
183
183
el = el . content
184
184
}
185
185
if ( el . hasChildNodes ( ) ) {
186
+ trim ( el , el . firstChild )
187
+ trim ( el , el . lastChild )
186
188
rawContent = asFragment
187
189
? document . createDocumentFragment ( )
188
190
: document . createElement ( 'div' )
@@ -194,6 +196,12 @@ exports.extractContent = function (el, asFragment) {
194
196
return rawContent
195
197
}
196
198
199
+ function trim ( content , node ) {
200
+ if ( node && node . nodeType === 3 && ! node . data . trim ( ) ) {
201
+ content . removeChild ( node )
202
+ }
203
+ }
204
+
197
205
/**
198
206
* Check if an element is a template tag.
199
207
* Note if the template appears inside an SVG its tagName
@@ -205,4 +213,4 @@ exports.extractContent = function (el, asFragment) {
205
213
exports . isTemplate = function ( el ) {
206
214
return el . tagName &&
207
215
el . tagName . toLowerCase ( ) === 'template'
208
- }
216
+ }
You can’t perform that action at this time.
0 commit comments