function applyToTag (styleElement, obj) {
var css = obj.css
// if (css && typeof css === 'string') {
// css = css.replace(/(\r\n|\r|\n)+/g,'');
// }
var media = obj.media
var sourceMap = obj.sourceMap
if (media) {
styleElement.setAttribute('media', media)
}
if (options.ssrId) {
styleElement.setAttribute(ssrIdKey, obj.id)
}
if (sourceMap) {
// https://developer.chrome.com/devtools/docs/javascript-debugging
// this makes source maps inside style tags work properly in Chrome
css += '\n/*# sourceURL=' + sourceMap.sources[0] + ' */'
// http://stackoverflow.com/a/26603875
css += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + ' */'
}
if (styleElement.styleSheet) {
styleElement.styleSheet.cssText = css
} else {
while (styleElement.firstChild) {
styleElement.removeChild(styleElement.firstChild)
}
if (css.replace(/(\r\n|\r|\n|\s)*/g,'') == '') {
styleElement.remove()
}
else {
styleElement.appendChild(document.createTextNode(css))
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)