diff --git a/lib/compile-vue.js b/lib/compile-vue.js index d2611ba..802fb70 100644 --- a/lib/compile-vue.js +++ b/lib/compile-vue.js @@ -16,7 +16,8 @@ import { STYLE_EXP, HTML_EXP, CSS_SHEET_EXP, - HMR_SCRIPT + HMR_SCRIPT, + V_DEEP } from './constants.js' const OPTIONS = { @@ -45,7 +46,18 @@ function scopeCss(css = '', hash) { let tmp = s.split(' ') let last = tmp.pop() if (last.includes(':')) { - last = last.replace(':', `[data-${hash}]:`) + let res = V_DEEP.exec(last) + if (res) { + last = tmp.pop() + last += `[data-${hash}] ` + res[1] + } else { + if (last.startsWith(':')) { + let _prev = tmp.pop() + last = `${_prev}[data-${hash}] ` + last + } else { + last = last.replace(':', `[data-${hash}]:`) + } + } } else { last += `[data-${hash}]` } diff --git a/lib/constants.js b/lib/constants.js index 2e7d9b7..2e943d6 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -7,6 +7,7 @@ export const JS_EXP = /]*?>([\w\W]*?)<\/script>/ export const STYLE_EXP = /]*?)>([\w\W]*?)<\/style>/g export const HTML_EXP = /]*?>([\w\W]*?)\n<\/template>/ +export const V_DEEP = /:deep\(([^)]*?)\)/ export const CSS_SHEET_EXP = /([@\w\.,#\-:>\+\~\|\(\)\[\]"'\=\s]+)\{/g diff --git a/package.json b/package.json index 593da87..d7c9282 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "fite", "type": "module", - "version": "0.4.0", + "version": "0.5.0", "bin": { "fite": "index.js" },