lttb / is-react-prop

MIT License
4 stars 1 forks source link

Implement attributes detection on the client #3

Closed lttb closed 6 years ago

lttb commented 7 years ago
import checkAttr from 'is-react-prop/checkAttr'

// the most efficient way

console.log(checkAttr('div', 'data-name')) // true
console.log(checkAttr('button', 'onClick')) // true
console.log(checkAttr('div', 'target')) // false
console.log(checkAttr(document.createElement('input'), 'onChange')) // true
import isReactProp from 'is-react-prop'

// it will add attributes list to the bundle

console.log(isReactProp('data-name')) // true
console.log(isReactProp('onClick')) // true
console.log(isReactProp('unknownProp')) // false
kof commented 7 years ago

is-react-prop project name doesn't fit, because it does much more

kof commented 7 years ago

cc @mxstbr @geelen @kentcdodds what do you think of this? What if we all had one package for this?

lttb commented 7 years ago

is-react-prop project name doesn't fit, because it does much more

@kof maybe is-html-attribute fits better?

kof commented 7 years ago

not really because you also have react specific stuff in there

kentcdodds commented 7 years ago

I'm planning on eventually making the glamorous solution totally tree-shakeable... 🤔

kof commented 7 years ago

I'm planning on eventually making the glamorous solution totally tree-shakeable... 🤔

what does this mean in this particular case?

kentcdodds commented 7 years ago

By that I mean that I might use a package like this, but only at build-time. Similar to what we're doing here which results in all the exports at the bottom of this file.