From fa3790e618a7e231674448c519ec58060164142a Mon Sep 17 00:00:00 2001 From: yutent Date: Tue, 28 Mar 2023 11:39:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0:deep()=E7=9A=84=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/compile-vue.js | 16 ++++++++++++++-- lib/constants.js | 1 + package.json | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) 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" },