-
Notifications
You must be signed in to change notification settings - Fork 20
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
Ready for React 16 #76
Conversation
Removed deprecated React code, switched examples to webpack, enforced AirBnb lint, added Replace Elements test. Signed-off-by: Frédéric Miserey <[email protected]>
Signed-off-by: Frédéric Miserey <[email protected]>
🎉 a lot of great updates @diligiant, thanks. One comment for now: can we not include dist? I'd like to avoid the need to update this file during development. Let's only include this on releases... |
An extraneous <span> was surrounding a replacement ending with a dual <span> for nothing. Signed-off-by: Frédéric Miserey <[email protected]>
or else simple FormattedText was output as individual characters (`“t””h””i””s”`). Added some test to prevent this as well as ensuring the proper structure of Replaced Elements. Borrowed alwaysArray from Globalizejs. Signed-off-by: Frédéric Miserey <[email protected]>
@rxaviers ok, will do. So basically, I leave you to include "dist" ? Ok boss ;) |
Elements substitution was incomplete when multiple elements were involved : If multiple substitutions of the same element occured when the format had been already splitted into multiple nodes, the last substitution(s) wouldn’t be applied as the last segment(s) wouldn’t be inspected. ForEach evaluated the length of the array at once and the array was expanded during the substitutions. The order of the elements in the new test is important: first [br] splits the format node into a 3-node array then [strong] should sustitute nodes to the first and last nodes. Renamed a few variables as well to enhance readability. Signed-off-by: Frédéric Miserey <[email protected]>
replaced for/forEach by map and flapMap. getElement param in spreadElemetsInBetweemItems is now always a function. Signed-off-by: Frédéric Miserey <[email protected]>
examples/package.json
Outdated
"babel-plugin-transform-class-properties": "^6.24.1", | ||
"babel-preset-react": "^6.24.1", | ||
"imports-loader": "^0.7.1", | ||
"webpack": "^3.5.4" | ||
}, |
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.
Let's add react ^16.0.0 in devDeps..
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.
I'm really not good at this! Isn't this a problem if deps are still ^15?
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.
Yeap, we should loose that in dev by adding the || 16
:)
examples/package.json
Outdated
"cldr-data": ">=31", | ||
"globalize": "^1.3.0", | ||
"react": "^15.6.0", | ||
"react-dom": "^15.6.1" |
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.
Shall we add a || ^16.0.0
?
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.
You're right. Damned ;) I also forgot to add my new fav example with markup ;)
examples/package.json
Outdated
}, | ||
"scripts": { | ||
"build": "mkdir -p react-globalize && cp ../dist/*.js react-globalize/ && browserify --debug --transform reactify index.js > app.js" | ||
"build": "mkdir -p react-globalize && cp ../dist/*.umd.js react-globalize/index.js && webpack" |
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.
👍
"test": "mocha test", | ||
"test:debug": "node ./node_modules/.bin/mocha --inspect-brk test", | ||
"lint": "eslint rollup.config.js src test", | ||
"pretest": "npm run lint" |
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.
🎉 Yay! No more grunt.
src/message.js
Outdated
|
||
if (typeof str !== "string") { | ||
return; // continue; | ||
for (let i = 0; i < nodes.length; i += 1) { |
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.
Great catch!
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.
ok. You'll notice I got rid of this ugly imperative coding in the next commit. Way safer.
Even if I switched to a safe flatMap, it might be nice to explain as it wasn’t done “just because” !! WDYT?
…On 2 Sep 2017 at 20:03 +0200, Rafael Xavier de Souza ***@***.***>, wrote:
@rxaviers commented on this pull request.
In src/message.js:
>
- if (typeof str !== "string") {
- return; // continue;
+ for (let i = 0; i < nodes.length; i += 1) {
Ignore my message asking to include a comment... This code has been modified anyway in subsequent commits.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
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.
Great job! Your changes LGTM.
Having said that, we definitely need to improve our tests in here, for example, assert element replacement in messages and others.
We should also move the default message approach into globalize itself. globalizejs/globalize#575
We could merge this and do those as later steps...
Thanks again
Let's give some time in case @necolas and @kborchers have any input... Otherwise, let's merge. |
👍, a brief explanation as an internal comment is definitely welcome. Also, it would be wise to include a test case to assert this doesn't regress in the future. |
Signed-off-by: Frédéric Miserey <[email protected]>
Signed-off-by: Frédéric Miserey <[email protected]>
Signed-off-by: Frédéric Miserey <[email protected]>
@rxaviers the test case is there (line 81 of test/formatMessage.spec.js) |
Do you want to handle this or may I? May you also take a look at #75 as it's the same area ; the purpose is to have a more predictable and logical behavior (and consistent with "normal" globalize). |
Signed-off-by: Frédéric Miserey <[email protected]>
Signed-off-by: Frédéric Miserey <[email protected]>
Signed-off-by: Frédéric Miserey <[email protected]>
Signed-off-by: Frédéric Miserey <[email protected]>
Signed-off-by: Frédéric Miserey <[email protected]>
Signed-off-by: Frédéric Miserey <[email protected]>
Which part of this patch is addressing React 16 compatibility? Can that be broken out into a separate PR so we can merge the React upgrade fix? |
@necolas all of it unless I'm mistaken! |
In this PR, along with React 16 upgrades (e.g., React.DOM.span -> React.createElement), there are its needed test upgrades (Enzyme 3), plus tooling and code modernization too. @diligiant can correct me if needed...
@necolas please are you looking for safety (prevent regressions) or speed (get this PR merged quickly)? I think at this point it will be hard to cherry-pick parts without having to deal with lots of conflicts, but it should be straightforward to merge this work into an upcoming 1.0.0 release according to #77 option (a). What do you think? |
Both. This PR has been open for a while and has a lot of unrelated changed. |
I opened #78 to handle only changes to make React 16 work and avoid all of the syntax and build system changes |
@paularmstrong thanks for creating #78. I also obviously prefer atomic PRs. Having said, we need to (a) assert if #78 is sufficient and (b) I don't think @diligiant work should be lost. The code and build improvements are welcome. @diligiant can you try to rebase your changes on top of #78? How much does it conflict? |
merge #78 and I’ll follow-up. |
Ref #76 Ref #80 Signed-off-by: Frédéric Miserey <[email protected]>
Ref #76 Ref #80 Signed-off-by: Frédéric Miserey <[email protected]>
or else simple FormattedText was output as individual characters (`“t””h””i””s”`). Added some test to prevent this as well as ensuring the proper structure of Replaced Elements. Borrowed alwaysArray from Globalizejs. Ref #76 Signed-off-by: Frédéric Miserey <[email protected]>
Elements substitution was incomplete when multiple elements were involved : If multiple substitutions of the same element occured when the format had been already splitted into multiple nodes, the last substitution(s) wouldn’t be applied as the last segment(s) wouldn’t be inspected. ForEach evaluated the length of the array at once and the array was expanded during the substitutions. The order of the elements in the new test is important: first [br] splits the format node into a 3-node array then [strong] should sustitute nodes to the first and last nodes. Renamed a few variables as well to enhance readability. Ref #76 Signed-off-by: Frédéric Miserey <[email protected]>
or else simple FormattedText was output as individual characters (`“t””h””i””s”`). Added some test to prevent this as well as ensuring the proper structure of Replaced Elements. Borrowed alwaysArray from Globalizejs. Ref globalizejs#76 Signed-off-by: Frédéric Miserey <[email protected]>
Elements substitution was incomplete when multiple elements were involved : If multiple substitutions of the same element occured when the format had been already splitted into multiple nodes, the last substitution(s) wouldn’t be applied as the last segment(s) wouldn’t be inspected. ForEach evaluated the length of the array at once and the array was expanded during the substitutions. The order of the elements in the new test is important: first [br] splits the format node into a 3-node array then [strong] should sustitute nodes to the first and last nodes. Renamed a few variables as well to enhance readability. Ref globalizejs#76 Signed-off-by: Frédéric Miserey <[email protected]>
This code now works with React 15 and React 16 (library and example). Tests will have to wait that enzyme is made compatible with React 16 to work.
3 versions of the library are now available: cjs, umd & esm.