From 3d33539a4a61b1d311aa82a1d03682e7cfe9544b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Wed, 6 May 2020 21:10:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=96=E8=AF=91=E8=84=9A?= =?UTF-8?q?=E6=9C=AC;=E5=A2=9E=E5=8A=A0=E8=A1=A8=E6=A0=BC=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.dev.js | 8 +++- build.prod.js | 8 +++- src/table/index.wc | 98 ++++++++++++++++++++++++++++++++++++++++++++++ src/table/item.wc | 21 ++++++++++ 4 files changed, 131 insertions(+), 4 deletions(-) create mode 100644 src/table/index.wc create mode 100644 src/table/item.wc diff --git a/build.dev.js b/build.dev.js index 54b7a6f..b388c32 100644 --- a/build.dev.js +++ b/build.dev.js @@ -45,6 +45,10 @@ $cd: #62778d #526273 #425064; ::after{box-sizing:border-box;} ` +function parseName(str) { + return str.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`).replace(/^\-/, '') +} + function fixImport(str) { return str .replace(/import '([\w-/_.]*)'/g, 'import "$1.js"') @@ -140,8 +144,8 @@ const log = console.log ${js} -if(!customElements.get('wc-${name.toLowerCase()}')){ - customElements.define('wc-${name.toLowerCase()}', ${name}) +if(!customElements.get('wc-${parseName(name)}')){ + customElements.define('wc-${parseName(name)}', ${name}) } ` } diff --git a/build.prod.js b/build.prod.js index a59ad27..4bdfaa8 100644 --- a/build.prod.js +++ b/build.prod.js @@ -45,6 +45,10 @@ $cd: #62778d #526273 #425064; ::after{box-sizing:border-box;} ` +function parseName(str) { + return str.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`).replace(/^\-/, '') +} + function fixImport(str) { return str .replace(/import '([\w-/_.]*)'/g, 'import "$1.js"') @@ -149,8 +153,8 @@ function mkWCFile({ style, html, js }) { ${res.code} -if(!customElements.get('wc-${name.toLowerCase()}')){ - customElements.define('wc-${name.toLowerCase()}', ${name}) +if(!customElements.get('wc-${parseName(name)}')){ + customElements.define('wc-${parseName(name)}', ${name}) } ` } diff --git a/src/table/index.wc b/src/table/index.wc new file mode 100644 index 0000000..3ce7af9 --- /dev/null +++ b/src/table/index.wc @@ -0,0 +1,98 @@ + + + + + diff --git a/src/table/item.wc b/src/table/item.wc new file mode 100644 index 0000000..3edc94d --- /dev/null +++ b/src/table/item.wc @@ -0,0 +1,21 @@ + + + + +