News for hackers. Stuff that matters.
Re:Shadow DOM by underwater on Thursday April 10, 2014 @01:22AM (#7564333)
I'm a bit confused by the potshots taken at React. React is a library for building components. The fact those components render down to DOM nodes is incidental. In fact the documentation[1] hints at other possibilities, like rendering to canvas elements or native iOS views.

1: http://facebook.github.io/react/blog/2013/06/05/why-react.ht...

Re:Shadow DOM by jonahx on Thursday April 10, 2014 @01:46AM (#7564389)
I was unclear, but as I understood it he was taking a shot at the whole html/css situation we're in that makes React, or anything like it, necessary.
Re:Shadow DOM by chenglou on Thursday April 10, 2014 @01:49AM (#7564399)
You're right! In fact, https://github.com/facebook/react-art is a React library we developed at Facebook for rendering graphics to Canvas, SVG, or VML, depending on what's fastest and what the browser supports.

It's in production currently. Documentation's lacking but go check it out if you feel adventurous =).

Re:Shadow DOM by davedx on Thursday April 10, 2014 @02:14AM (#7564453)
I work in digital TV, and we've been experimenting with using WebGL to build our interfaces lately as rendering the DOM on the GPU is so messy and complicated. Is there any prospect of a WebGL renderer for React? If not, how difficult would such a thing be to build by an eager third party? :)
Re:Shadow DOM by spicyj on Thursday April 10, 2014 @02:36AM (#7564509)
(I work on React.) I don't know of anyone who's put work into a WebGL renderer, but it should be possible. There are a few pieces of React that still assume that you're rendering to the DOM but you can see that the react-art source is only around 600 lines for bindings to the underlying https://github.com/sebmarkbage/art drawing library so it shouldn't be too hard (knock on wood!).
Re:Shadow DOM by greggman on Thursday April 10, 2014 @04:15AM (#7564806)
Unless I'm missing something the problem with canvas based shadow dom widgets is there is no per element resize event so if the element gets resized there's no way for the element to know it needs to redraw its content. The only resize event in the browser is on window so sizing a column for example or having an element's size change based on adding or removing other elements does not generate any events the shadow dom element would have access to
Re:Shadow DOM by vjeux on Thursday April 10, 2014 @07:43AM (#7565308)
If you use any renderer outside of the DOM then you need to implement your own layout engine. It means that you've got to figure out for each node that you output its left, top, width, height. CSS has its flaws but makes 95% of the use cases really easy to work with compared to any ofher mainstream UI abstraction.
Re:Shadow DOM by greggman on Thursday April 10, 2014 @02:16PM (#7568545)
As a simple example though, assume you wanted to make a Shadow DOM widget to show a visual representation of an audio sample, or any other kind of detailed graph. Something you arguably don't want to build a giant SVG tree for. Those seem like great things to do with shadow dom widgets... but ... they seem S.O.L without a per element resize event.

I suppose that's being a little over the top. As long as you make them a fixed size or manually call some 'redraw' function when your app notices they've been resized then you're fine. It's just part of the point of Shadow DOM is you're not suppose to have to do that. They should "just work" just like normal HTML elements and size and redraw themselves. It would be nice if there was a way to do that for more interesting canvas based widgets.

Re:Shadow DOM by lobo_tuerto on Thursday April 10, 2014 @05:23PM (#7569827)
You might be interested in this then (Famo.us): https://news.ycombinator.com/item?id=7558261
Re:Shadow DOM by davedx on Tuesday April 22, 2014 @10:36AM (#7627882)
We've looked at Famo.us too. In fact I've benchmarked the famo.us approach on our hardware, unfortunately for what we're doing CSS transitions appear to be marginally smoother.
Re:Shadow DOM by ttty on Thursday April 10, 2014 @06:48AM (#7565151)
You could use PIXI.js
Re:Shadow DOM by haberman on Thursday April 10, 2014 @03:01AM (#7564561)
Not dissing React, but the Shadow DOM is a leaky abstraction that sometimes needs to be violated (by accessing the real DOM directly) to get things like focus right. More info here: http://facebook.github.io/react/docs/working-with-the-browse...
Re:Shadow DOM by ttty on Thursday April 10, 2014 @06:49AM (#7565152)
You're saying "but the Virtual DOM is a leaky abstraction"?