Allow setting component properties through JS properties, not only setAttribute()
See original GitHub issueThe standard setAttribute() function on DOM elements is defined to accept a string for both the attribute name and value. A-Frame breaks this standard by allowing the value passed in to be an arbitrary object.
This could be brushed away as inconsequential, except Elm’s fantastic HTML library and virtual DOM expects attributes to be strings, and thus offers no way to take advantage of A-Frame’s more efficient object-passing approach.
Browsers provide another interface to set attributes: through JS properties. Mutating A-Frame components this way would change the interface from:
entity.setAttribute('position', {x: 1, y: 2, z: 3})
to:
entity.position = {x: 1, y: 2, z: 3}
Apart from it being more concise and maintaining consistency with regular HTML, adding such an interface would enable object assignment to be used in Elm, since Elm provides a means to specify DOM element properties.
This interface to set properties might also provide the opportunity to alleviate some of the overhead associated with the current setAttribute().
Issue Analytics
- State:
 - Created 6 years ago
 - Comments:8 (4 by maintainers)
 

Top Related StackOverflow Question
@ngokevin I’m also interested in why this wouldn’t be possible.
Elm isn’t built for just the 2D web; there’s even a WebGL package for Elm.
Elm’s killer feature is its declarative app architecture which lets you map Model -> View without the usual mess of glue code. Elm’s declarative app architecture paired with A-Frame’s rock-solid VR and WebGL abstractions would be insanely cool. The cherry on top is that A-Frame is already declarative and DOM-based, which means Elm is tantalizingly close to working with A-Frame out of the box (and kind of did up to 412d162).
Their names even pun together 😉 It would be an absolute tragedy if Elm and A-Frame couldn’t play well together.
PS: Thanks for creating A-Frame. It’s awesome by itself!
If there’s a reason why this API is not reasonable, then that’s fine. But you don’t seemed to have justified why you couldn’t use properties.
On Wed, 4 Apr 2018 at 9:42 pm, Kevin Ngo notifications@github.com wrote: