Closed jridgewell closed 9 years ago
@thejameskyle: Would you mind reviewing this?
Looking now
Can we change some code style stuff in here as well:
enter
visitors`.
node
, makes it easier follow I think
Sorry for the massive comment
Then @thejameskyle made it even bigger. :stuck_out_tongue:
I'm just bumping your commit count, that's all.
Looks good
btw @jridgewell, @sebmck mentioned to me earlier that he's going to be enforcing linting rules across plugins in this org in the future
https://github.com/babel-plugins/babel-plugin-incremental-dom/commit/eb1b72cbf6aee5be6dcbdfdda7f6f20221a1cac4 is a breaking change. V2?
enforcing linting rules across plugins in this org in the future
Is there are an lint configuration?
@jridgewell
Is there are an lint configuration?
Re: eb1b72c
I'm now confused by this change, <div>{"Hello"}</div>
is treated the same as <div>Hello</div>
in React isn't it?
I'm now confused by this change,
<div>{"Hello"}</div>
is treated the same as<div>Hello</div>
in React isn't it?
Literals and implied text (<div>hello</div>
) are treated the same. That commit changes the following:
<div>{hello}</div>
<div>{obj.hello}</div>
Using the online compiler to test, hello
and obj.hello
can reference a React Element which will be inserted as a child. That doesn't make sense for iDOM, since you can't return an element to insert it — only calling one of the iDOM functions will do anything.
This seems like a pretty significant issue. Do you think there's any way for idom to support this case?
<div>{'text'}</div>
elementOpen('div')
renderArbitrary('text')
elementClose('div')
<div>{<div></div>}</div>
elementOpen('div')
renderArbitrary((elementOpen('div'), elementClose('div'))
elementClose('div')
Working alongside https://github.com/google/incremental-dom/pull/75
This seems like a pretty significant issue. Do you think there's any way for idom to support this case?
Without a pretty big renderArbitrary
and a lot of edge cases, no it's not. google/incremental-dom#75 will get us some of the way, but that'll still return a fleshed DOM node. The helper would have to scrape it for the tagName
, key
, attrs
, and recurse into the children.
You'd be prevented from using statics
, because it wouldn't be possible to determine if the particular attribute will change in the future.
I'm not even sure if that covers all of the possibilities JSX does.
var node = (elementOpen('div', key, ['class', 'test', 'key', key], id, x), elementClosed('div');
console.log(node); // => <div key="123" class="test" id="abc"></div>
function renderArbitrary(node) {
if (isElement) {
// scrape tag, key, attributes, and recurse into children
} else if (isTextNode) {
text(node.data);
} else if (isString) {
text node.data;
} else if (isObject) {
_.each(node, renderArbitrary);
}
};
I think this is an issue with the differences between the renderers (React v iDOM), not the JSX -> iDOM compilation.
Is there any way we can support the text case? This basically gets rid of the possibility of using dynamic text content minus using idom directly.
Is there any way we can support the text case?
Certainly, let me work on that.
Whew, this got a little too big. Then @thejameskyle made it even bigger. :stuck_out_tongue:
text()
Identifier
s andMemberExpression
s (eb1b72cbf6aee5be6dcbdfdda7f6f20221a1cac4)elementOpenStart
(205df8455a5064b6f2d785f43e71797726f930e0)