css: iOS doesn't allow writing "style" property

This commit is contained in:
jean-emmanuel 2018-03-21 14:49:50 +01:00
parent 8aa2735ce1
commit a94ee973c1
2 changed files with 18 additions and 2 deletions

View file

@ -4,6 +4,7 @@
- bug fixes
- session/state file upload sometimes failing silently
- regression breaking the app for iOS
## 0.27.1

View file

@ -564,8 +564,23 @@ class Widget extends EventEmitter {
scopedCss = scopeCss(css, prefix),
unScopedCss = ''
dummyDOM.style = css
unScopedCss = dummyDOM.getAttribute('style') || ''
try {
dummyDOM.style = css
unScopedCss = dummyDOM.getAttribute('style') || ''
} catch(err) {
// fallback for browser that don't allow assigning "style" property
this.getProp('css')
.replace(/\{[^\}]*\}/g, '')
.replace(/^[^@#\.]*\:.*/gm, (m) => {
unScopedCss += m[m.length - 1] === ';' ? m : m + ';'
})
}
if (scopedCss.indexOf('@keyframes') > -1) scopedCss = scopedCss.replace(new RegExp(prefix + '\\s+([0-9]+%|to|from)', 'g'), ' $1')
if (scopedCss.indexOf('&') > -1) scopedCss = scopedCss.replace(new RegExp(prefix + '\\s&', 'g'), prefix)