diff --git a/src/html.js b/src/html.js
index a729c2a..70c8f53 100644
--- a/src/html.js
+++ b/src/html.js
@@ -13,11 +13,13 @@ const MARKER = `{{^wkit${String(Math.random()).slice(-8)}^}}`
const MARKER_MATCH = '?' + MARKER
const NODE_MARKER = `<${MARKER_MATCH}>`
+// 是否原始值
const isPrimitive = value =>
- value === null || (typeof value != 'object' && typeof value != 'function')
+ value === null || (typeof value !== 'object' && typeof value !== 'function')
const isArray = Array.isArray
const isIterable = value =>
value ? isArray(value) || typeof value[Symbol.iterator] === 'function' : false
+
const SPACE_CHAR = `[ \n\f\r]`
const ATTR_VALUE_CHAR = `[^ \n\f\r"'\`<>=]`
const NAME_CHAR = `[^\\s"'>=/]`
@@ -573,10 +575,15 @@ class AttributePart {
elem.removeAttribute(attr)
}
} else {
- if (value === null || value === void 0) {
- elem.removeAttribute(attr)
+ // value 绑定, 特殊处理
+ if (attr === 'value') {
+ elem.value = value
} else {
- elem.setAttribute(attr, value)
+ if (value === null || value === void 0) {
+ elem.removeAttribute(attr)
+ } else {
+ elem.setAttribute(attr, value)
+ }
}
}
}