parser: add support for "&" self selector

This commit is contained in:
jean-emmanuel 2017-03-15 15:56:01 +01:00
parent 5d288848f3
commit 9f5def635b

View file

@ -185,7 +185,11 @@ module.exports.widgets = function(data,parent) {
css = css.replace(/[;\}]*([^\;\{]*\{[^\}]*\})/g, (m)=>{
if (m[0]==';') m = m.substr(1,m.length)
scopedCss += '${id}' + m
if (m[0]=='&') {
scopedCss += m
} else {
scopedCss += '& ' + m
}
return ''
})
@ -212,7 +216,7 @@ module.exports.widgets = function(data,parent) {
// apply scoped css
if (scopedCss.length) {
widgetContainer.attr('id', 'widget-' + widgetInner.hash)
scopedCss = scopedCss.split('${id}').join('#widget-' + widgetInner.hash + ' ')
scopedCss = scopedCss.split('&').join('#widget-' + widgetInner.hash)
widgetContainer.prepend(`<style>${scopedCss}</style>`)
}