-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow RootElements and RootContainers to specify their node type #532
Changes from 3 commits
c5202aa
0fbc64b
3099089
9a6d065
48f83f4
99b7227
b09a5dc
8d362c1
0d91e5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,9 +23,11 @@ RootContainer.defaultProps = { | |
} | ||
|
||
RootContainer.flattenForRender = function(element) { | ||
return [{containerOpen: getRootElementAttributes(element)}] | ||
let attrs = getRootElementAttributes(element) || {}; | ||
attrs.tagName = attrs.tagName || 'div'; | ||
return [{containerOpen: true, attrs: attrs}] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something like |
||
.concat(prepChildren(element)) | ||
.concat([{containerClose: true}]) | ||
.concat([{containerClose: true, attrs: attrs}]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then this could just be |
||
.reduce((m,v) => m.concat(Array.isArray(v)?v:[v]), []) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,7 +103,7 @@ RootElement.getRootElementAttributes = function(element) { | |
'id', | ||
'style', | ||
].forEach(k => props[k] && (attrs[k] = props[k])); | ||
|
||
attrs.tagName = props.tagName || 'div'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't bundle this in with The tag name is a different beast. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, I was waffling a bit on that one, flipped a coin and came out this way. I think I agree with you that the other way is easer to read. |
||
return attrs; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bit actually isn't necessary. The attributes we pass through are white listed in RootElement.js.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I hadn't gotten far enough... looks like it's being added as an attr there now. Hmm...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, its a kinda ugly bit of code. No harm arises by putting the attribute on the node, but its redundant information because the node with be of the type specified so I chose to exclude it.