|
|
@@ -183,6 +183,8 @@ exports.extractContent = function (el, asFragment) {
|
|
|
el = el.content
|
|
|
}
|
|
|
if (el.hasChildNodes()) {
|
|
|
+ trim(el, el.firstChild)
|
|
|
+ trim(el, el.lastChild)
|
|
|
rawContent = asFragment
|
|
|
? document.createDocumentFragment()
|
|
|
: document.createElement('div')
|
|
|
@@ -194,6 +196,12 @@ exports.extractContent = function (el, asFragment) {
|
|
|
return rawContent
|
|
|
}
|
|
|
|
|
|
+function trim (content, node) {
|
|
|
+ if (node && node.nodeType === 3 && !node.data.trim()) {
|
|
|
+ content.removeChild(node)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* Check if an element is a template tag.
|
|
|
* Note if the template appears inside an SVG its tagName
|
|
|
@@ -205,4 +213,4 @@ exports.extractContent = function (el, asFragment) {
|
|
|
exports.isTemplate = function (el) {
|
|
|
return el.tagName &&
|
|
|
el.tagName.toLowerCase() === 'template'
|
|
|
-}
|
|
|
+}
|