Skip to content

Commit a11b353

Browse files
committed
Make sheet with min options
1 parent cac6c98 commit a11b353

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

dom.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,7 @@ var boolAttrs = {
111111
this.parentNode.replaceChild(frag, this)
112112
},
113113
get sheet() {
114-
if (this.tagName === "STYLE" || this.tagName === "LINK" && this.rel === "stylesheet" && this.href) return new CSSStyleSheet({
115-
href: this.href,
116-
ownerNode: this
117-
}, this.tagName === "STYLE" && this.textContent)
114+
return makeSheet(this)
118115
},
119116
get style() {
120117
return this._style || (this._style = CSSStyleDeclaration(this.getAttribute("style") || ""))
@@ -187,7 +184,7 @@ var boolAttrs = {
187184
},
188185
toString(min) {
189186
return rawTextElements[this.tagName] ? (
190-
this.tagName === "STYLE" && (min === true || min && min.css) ? "\n" + this.sheet.toString(min.css || true) + "\n" :
187+
this.tagName === "STYLE" && (min === true || min && min.css) ? "\n" + makeSheet(this, min.css || true) + "\n" :
191188
this.textContent
192189
) : this.childNodes.map(node => node.toString(min)).join("")
193190
}
@@ -491,6 +488,14 @@ function getSibling(node, step, type) {
491488
return type > 0 ? getElement(silbings, index + step, step, type) : silbings && silbings[index + step] || null
492489
}
493490

491+
function makeSheet(el, min) {
492+
if (el.tagName === "STYLE" || el.tagName === "LINK" && el.rel === "stylesheet" && el.href) return new CSSStyleSheet({
493+
href: el.href,
494+
ownerNode: el,
495+
min
496+
}, el.tagName === "STYLE" && el.textContent)
497+
}
498+
494499
function mergeAttributes(source, target) {
495500
if (source && target && source.attributes) {
496501
source.attributes.names().forEach(attr => target.setAttribute(attr, source.getAttribute(attr)))

0 commit comments

Comments
 (0)