From c56013c9b4563baf7e7699777aa6877d8fd939a7 Mon Sep 17 00:00:00 2001 From: yutent Date: Sat, 11 May 2024 18:44:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96props=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/constants.js | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 70015d4..2f8d30c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wkit", - "version": "1.11.3", + "version": "1.11.4", "type": "module", "description": "A library for building fast, lightweight web components.", "main": "dist/index.js", diff --git a/src/constants.js b/src/constants.js index 0ea5289..3dcafc4 100644 --- a/src/constants.js +++ b/src/constants.js @@ -83,16 +83,14 @@ function getType(v) { let type = String let attribute = true if (v.includes('!')) { - v = v.split('!') - let _t = v.shift() - if (_t === 'str') { - v = v.join('!') - } else if (_t === 'num') { + if (v.startsWith('str!')) { + v = v.slice(4) + } else if (v.startsWith('num!')) { type = Number - v = +v.shift() || 0 - } else if (_t === 'bool') { + v = +v.slice(4) || 0 + } else if (v.startsWith('bool!')) { type = Boolean - v = v.shift() + v = v.slice(5) v = v !== 'false' && v !== '' } attribute = false