Skip to content

Commit bdd9030

Browse files
committed
fix(index): dynamic css loading support for older browsers (#294)
1 parent 7d1e0ca commit bdd9030

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Diff for: src/index.js

+12
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,18 @@ class MiniCssExtractPlugin {
379379
: '',
380380
'var head = document.getElementsByTagName("head")[0];',
381381
'head.appendChild(linkTag);',
382+
"// old webkit's would claim to have onload, but didn't really support it",
383+
'// https://github.com/kriszyp/xstyle/blob/master/core/load-css.js',
384+
'var webkitVersion = navigator.userAgent.match(/AppleWebKit\\/(\\d+\\.?\\d*)/);',
385+
'webkitVersion = webkitVersion && +webkitVersion[1];',
386+
'if (webkitVersion < 536) {',
387+
Template.indent([
388+
'// http://www.backalleycoder.com/2011/03/20/link-tag-css-stylesheet-load-event/',
389+
'var img = document.createElement("img");',
390+
'img.onerror = resolve;',
391+
`img.src = fullhref;`,
392+
]),
393+
'}',
382394
]),
383395
'}).then(function() {',
384396
Template.indent(['installedCssChunks[chunkId] = 0;']),

0 commit comments

Comments
 (0)