Enyo question about DOM updating

edited July 2014 in General
I was at a talk about React.js and thought it was very similar to Enyo. It seems the main benefit is this whole virtual DOM idea, where changes to the DOM are limited and only applyed if the state of the virtual DOM is different from the real DOM.

Does Enyo employ techniques like this. I got into a discussion with someone who used Enyo claiming that an Enyo object is tied one to one to the DOM and any changes made to an Enyo object propagates straight to DOM. That is incorrect though as most changes need a render or update called on it's component.

Also if render is called on a parent component will children components get rerendered to the DOM if there are no changes?


  • edited July 2014
    I haven't experimented with React yet but, from what I've read, there are some similarities. For example, Enyo does maintain its own in-memory component heirarchy separate from the DOM. There are several advantages to this but specific to your question, it allows the framework to retrieve and manipulate the components without necessarily accessing the DOM.

    However, if you update something that is represented in the DOM, it will be written to the DOM immediately without the need for a explicit render(). For example, if you've created a generic enyo.Control and call control.set('content', 'New Content') the new innerHTML will be updated immediately (assuming the control has been rendered once).

    This is no different that React, as far as I can tell, and likely what you'd expect. It'd be too verbose to have to call set() and render() every time.

    To your last comment, if you render() a Control, it will render it and all of its children. If they've already been rendered, they'll be torn down and re-rendered. Normally, this isn't something you will need to do but it is used in some scenarios. If, instead, you've only updated an attribute (e.g. style) of a parent control, it will update that DOM attribute directly and will not re-render the control and its children.

    Hope that helps!
Sign In or Register to comment.