feat: support custom elements in React 16#78
feat: support custom elements in React 16#78remarkablemark merged 1 commit intoremarkablemark:masterfrom bschlenk:support-custom-elements
Conversation
remarkablemark
left a comment
There was a problem hiding this comment.
Thanks for creating the PR @bschlenk, I added some comments. Let me know what you think
| */ | ||
| function attributesToProps(attributes) { | ||
| attributes = attributes || {}; | ||
| function attributesToProps(attributes = {}) { |
There was a problem hiding this comment.
revert: can we undo this line change since the library isn't transpiled and I wouldn't want the ES6 syntax to break for other users
| /** | ||
| * Check if a given tag is a custom component. | ||
| * | ||
| * @see https://github.com/facebook/react/blob/master/packages/react-dom/src/shared/isCustomComponent.js |
There was a problem hiding this comment.
docs: could you use the following link instead: https://github.com/facebook/react/blob/v16.6.3/packages/react-dom/src/shared/isCustomComponent.js
This way, it's likely to 404 if it moves around
| */ | ||
| function isCustomComponent(tagName, props) { | ||
| if (tagName.indexOf('-') === -1) { | ||
| return props && typeof props.is === 'string'; |
There was a problem hiding this comment.
docs: do you mind adding a comment about the custom elements specification (https://www.w3.org/TR/2016/WD-custom-elements-20161013/#attr-is)
| * | ||
| * @return {boolean} | ||
| */ | ||
| function reactSupportsUnknownAttributes() { |
There was a problem hiding this comment.
perf: can we memoize the value here to minimize execution cycles?
var PRESERVE_CUSTOM_ATTRS = React.version.split('.')[0] >= 16;
// JS will coerce the value to number due to the comparison
// http://www.ecma-international.org/ecma-262/5.1/#sec-11.8.5refactor: can we rename the value as PRESERVE_CUSTOM_ATTRS (so it follows the convention of a constant) and add a comment to the blog post above the line?
The only disadvantage of this approach is that the value isn't readonly or a constant so it's possible for others to override it
| const attributesToProps = require('../lib/attributes-to-props'); | ||
|
|
||
| describe('attributesToProps', () => { | ||
| let actualReactVersion; |
| const { data, render } = require('./helpers/'); | ||
|
|
||
| describe('dom-to-react parser', () => { | ||
| let actualReactVersion; |
| }); | ||
|
|
||
| describe('utilities.reactSupportsUnknownAttributes', () => { | ||
| let actualVersion; |
To not block this PR from getting merged, I'll make the fixes/changes on my side
…ments feat: support custom elements in React 16
Closes #77