优化props解析

master
yutent 2024-05-11 18:44:03 +08:00
parent db7098c4f8
commit c56013c9b4
2 changed files with 7 additions and 9 deletions

View File

@ -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",

View File

@ -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