hmans / three-elements

Web Components-powered custom HTML elements for building Three.js-powered games and interactive experiences. 🎉
https://three-elements.hmans.co
MIT License
398 stars 14 forks source link

BaseElement.setAttribute should track super.setAttribute succes/failure #153

Open devingfx opened 2 years ago

devingfx commented 2 years ago

Hello

This is a (very) small issue though, but reading this lines in file : https://github.com/hmans/three-elements/blob/a580feb5f1c537d19387c3630703734c5f835644/packages/three-elements/src/BaseElement.ts#L115-L118

... I assume wrong arguments can be given (like wrong attributeName) for the native impl. to throw an error.
In this case, the attributeChangedCallback will be called even the actual attribute set is not terminated...

Easy solution: invert the 2 lines, so the callback would not be fired if an error occured. Less easy solution: Encapsulate the super call in a try/catch and call the callback only in case of success, and manage the error case...