pomber / didact

A DIY guide to build your own React
https://pomb.us/build-your-own-react/
6.29k stars 531 forks source link

How to handle styling? #51

Open Lioncat2002 opened 1 year ago

Lioncat2002 commented 1 year ago

How do I handle inline styling? currently something like

<div style{{background:"black"}}></div>

gets converted to

<div style></div>
1111PP commented 1 week ago

change function: updateDom add this code

  const styleObj = newProps.style || {}
  Object.keys(styleObj).forEach((key) => (dom.style[key] = styleObj[key]))

and change function : isProperty const isProperty = (key) => key !== 'children' && !isEvent(key) && key !== 'style'