From c7376e159558b1603be52d3b1d114b0a598d7b74 Mon Sep 17 00:00:00 2001 From: yutent Date: Fri, 29 Mar 2024 14:00:49 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4attr=E8=BD=ACstyle=E7=9A=84?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/elem.js | 7 +++-- src/lib/constants.js | 64 -------------------------------------------- src/utils.js | 5 ---- 3 files changed, 3 insertions(+), 73 deletions(-) diff --git a/src/elem.js b/src/elem.js index 9551803..7c8e521 100644 --- a/src/elem.js +++ b/src/elem.js @@ -75,16 +75,15 @@ export class Component { let out = {} if (key) { - let attrs = key + let props = key if (typeof key === 'string') { if (val === void 0) { return node.getAttribute(key) } else { - attrs = { [key]: val } + props = { [key]: val } } } - - h(node, attrs) + h(node, props) return this } diff --git a/src/lib/constants.js b/src/lib/constants.js index 4f240b6..684f133 100644 --- a/src/lib/constants.js +++ b/src/lib/constants.js @@ -18,67 +18,3 @@ export const SPEC_ATTR = { patternTransform: 1, patternContentUnits: 1 } - -export const CSS_ATTR = { - 'alignment-baseline': 1, - 'baseline-shift': 1, - clip: 1, - 'clip-path': 1, - 'clip-rule': 1, - color: 1, - 'color-interpolation': 1, - 'color-interpolation-filters': 1, - 'color-profile': 1, - 'color-rendering': 1, - cursor: 1, - direction: 1, - display: 1, - 'dominant-baseline': 1, - 'enable-background': 1, - fill: 1, - 'fill-opacity': 1, - 'fill-rule': 1, - filter: 1, - 'flood-color': 1, - 'flood-opacity': 1, - font: 1, - 'font-family': 1, - 'font-size': 1, - 'font-size-adjust': 1, - 'font-stretch': 1, - 'font-style': 1, - 'font-variant': 1, - 'font-weight': 1, - 'glyph-orientation-horizontal': 1, - 'glyph-orientation-vertical': 1, - 'image-rendering': 1, - kerning: 1, - 'letter-spacing': 1, - 'lighting-color': 1, - marker: 1, - 'marker-end': 1, - 'marker-mid': 1, - 'marker-start': 1, - mask: 1, - opacity: 1, - overflow: 1, - 'pointer-events': 1, - 'shape-rendering': 1, - 'stop-color': 1, - 'stop-opacity': 1, - stroke: 1, - 'stroke-dasharray': 1, - 'stroke-dashoffset': 1, - 'stroke-linecap': 1, - 'stroke-linejoin': 1, - 'stroke-miterlimit': 1, - 'stroke-opacity': 1, - 'stroke-width': 1, - 'text-anchor': 1, - 'text-decoration': 1, - 'text-rendering': 1, - 'unicode-bidi': 1, - visibility: 1, - 'word-spacing': 1, - 'writing-mode': 1 -} diff --git a/src/utils.js b/src/utils.js index aaea146..4fec283 100644 --- a/src/utils.js +++ b/src/utils.js @@ -10,7 +10,6 @@ import { xhtmlns, HTML_TAGS, SPEC_ATTR, - CSS_ATTR, doc, win } from './lib/constants.js' @@ -71,10 +70,6 @@ export function h(el, props = null, children) { if (val === null) { el.removeAttribute(key) } else { - if (CSS_ATTR[key]) { - el.style.cssText += `${key}:${props[key]};` - continue - } el.setAttribute(key, val) } }