Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should element behaviors be accessible on elements directly, or in a global map? #1

Open
trusktr opened this issue Feb 1, 2018 · 1 comment

Comments

@trusktr
Copy link
Member

trusktr commented Feb 1, 2018

For example, should it be

const el = document.querySelector('div')

// suppose el is <div has="foo bar baz">

el.behaviors.add('click-logger')
el.behaviors.remove('foo')

// now el is <div has="bar baz click-logger">

which means .behaviors would exist on Element.prototype, or should it be something like

const el = document.querySelector('div')

// suppose el is <div has="foo bar baz">

elementBehaviors.of(el).add('click-logger')
elementBehaviors.of(el).remove('baz')

// now el is <div has="bar baz click-logger">

It seems like a global map would be easier to optimize, rather than increasing the size of the prototype of all elements by default. ?

@drBenway
Copy link

I think global is a good idea. This feature is also missing for custom elements .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants