Skip to content

[css-typed-om] Consider using properties in addition to .get/.set #310

@esprehn

Description

@esprehn

Real properties are faster since we can cache the property lookup, ex.

element.styleMap.color // => JS VM can cache the lookup for color

It also lets the getter/setter cache the "color" => engine representation conversion where most (all?) engines convert to an enum as there's a specific method for every property.

Note we'd still need .get(name) and .set(name) to deal with custom properties, since we don't want to add more named getters, ex. map.get("--foo"). vs map["--foo"].

The disadvantage of this approach is that it means StyleMap has 400+ properties like CSSStyleDeclaration does, and every new CSS property is implicitly adding new properties. It also means if maps get a new method called "filter", and we wanted StyleMap to be really maplike, we'd end up colliding with CSS's filter property.

@bzbarsky

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions