-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Gallerys ids are saved as numbers #19163
Merged
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
da3f096
Make sure gallery ids are always numbers.
SergioEstevao 1d3582f
Implement deprecation path from post where ids can be strings.
SergioEstevao 0ee6636
Improve is eligible method to apply only when strings are in the ids …
SergioEstevao 514bce7
Remove spaces on empty arrays.
SergioEstevao ab5f0d2
Remove spaces on empty arrays.
SergioEstevao 41e8c25
Fix indentation.
SergioEstevao 4587f69
Fix indent spaces.
SergioEstevao 5494893
Merge branch 'master' into rnmobile/gallerys_ids_type
SergioEstevao b3a90fe
Add deprecation test for gallery with string ids.
SergioEstevao b0211d7
Use some instead of reduce.
SergioEstevao fc4d8bb
Merge branch 'master' into rnmobile/gallerys_ids_type
SergioEstevao b40dca1
Simplify the code for parsing id.
SergioEstevao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is there any opportunity for code reuse in any of these properties or functions? Merging attributes using
Object.assign
/ spread? Reference a commonsave
function?This is a lot of code to coerce an array to a typed array.
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.
@aduth I considerer shared code with the current version of save, but then I saw this comment on the block deprecations documentation:
Is this still a valid concern? Or I can share code without problems with the current version of save?
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.
The problem is that if you inherit from the current attributes, the deprecations may work now but not later if more attributes are added to the block. If you add an optional
thingy
attribute to the current block, and your deprecations inherit the entire attributes object from the current implementation, then all the deprecations will stop working. If you change an existing attribute, you have to remember to modify every single deprecation to stop inheriting from the current implementation.Hardcoding the deprecation definitions, although verbose, is a more robust solution. I don't really see it as much of problem since the deprecations are now usually put in a separate file from the rest of the block data.
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.
Yeah, I prefer the longer safer option. Though it's generally ok if there are tests in place.
Which is something I think should be considered for this PR, ideally a
core__gallery__deprecated-4.html
fixture would be added in this folder:https://github.com/WordPress/gutenberg/tree/master/packages/e2e-tests/fixtures/blocks
The way I generally do this is:
core__gallery__deprecated-4.html
in thepackages/e2e-tests/fixtures/blocks
folder.GENERATE_MISSING_FIXTURES=y npm run test-unit test/integration/full-content/full-content.test.js