移除attr转style的逻辑

master
yutent 2024-03-29 14:00:49 +08:00
parent f5321e219a
commit c7376e1595
3 changed files with 3 additions and 73 deletions

View File

@ -75,16 +75,15 @@ export class Component {
let out = {} let out = {}
if (key) { if (key) {
let attrs = key let props = key
if (typeof key === 'string') { if (typeof key === 'string') {
if (val === void 0) { if (val === void 0) {
return node.getAttribute(key) return node.getAttribute(key)
} else { } else {
attrs = { [key]: val } props = { [key]: val }
} }
} }
h(node, props)
h(node, attrs)
return this return this
} }

View File

@ -18,67 +18,3 @@ export const SPEC_ATTR = {
patternTransform: 1, patternTransform: 1,
patternContentUnits: 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
}

View File

@ -10,7 +10,6 @@ import {
xhtmlns, xhtmlns,
HTML_TAGS, HTML_TAGS,
SPEC_ATTR, SPEC_ATTR,
CSS_ATTR,
doc, doc,
win win
} from './lib/constants.js' } from './lib/constants.js'
@ -71,10 +70,6 @@ export function h(el, props = null, children) {
if (val === null) { if (val === null) {
el.removeAttribute(key) el.removeAttribute(key)
} else { } else {
if (CSS_ATTR[key]) {
el.style.cssText += `${key}:${props[key]};`
continue
}
el.setAttribute(key, val) el.setAttribute(key, val)
} }
} }