Skip to content
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

Improve the Block Validation and Deprecation flows #13611

Closed
bfintal opened this issue Jan 31, 2019 · 3 comments
Closed

Improve the Block Validation and Deprecation flows #13611

bfintal opened this issue Jan 31, 2019 · 3 comments
Labels
[Feature] Block API API that allows to express the block paradigm. [Type] Enhancement A suggestion for improvement.

Comments

@bfintal
Copy link
Contributor

bfintal commented Jan 31, 2019

Is your feature request related to a problem? Please describe.
Even a tiny edit in the block's save method results in a block error.

During validation, the block's HTML structure is checked. It makes blocks really sensitive and susceptible to block errors when something in the block gets updated, e.g. when a new feature is added.

Describe the solution you'd like
I would like to propose to change this methodology. Instead of checking the expected output HTML, just run the validation thru the attribute parameters.

Old validation rules:

  • Try and parse the attributes from the saved HTML, if we can't get them, fail it.
  • Render the output using those attributes, if the output doesn't match the saved HTML, fail it.

New validation rule:

  • Try and parse the attributes from the saved HTML, if we can't get them, fail it.

It doesn't matter when the actual output HTML is a little bit different, as long as the attributes CAN be parsed, the output should be assumed to be good. If the attributes cannot be parsed, then that's the only time the block should be deprecated.

Inspired by @fklein-lu's comment in #12708 (comment)

Describe alternatives you've considered

  • Lots of deprecated code - some of my blocks already have 5 deprecations
  • Testing against a lot of old saved block outputs - you'll have to test vs multiple outputs of old block versions with different attribute values
@swissspidy swissspidy added [Type] Enhancement A suggestion for improvement. [Feature] Block API API that allows to express the block paradigm. labels Jan 31, 2019
@HardeepAsrani
Copy link
Contributor

As someone who made a 600 lines long deprecation method (even if it was just a copy and paste from edit function) because we removed a single CSS class, this issue is a light of hope. 😭

@youknowriad
Copy link
Contributor

I had a discussion about this with @joemcgill and this proposal as it stands won't work. For example

<!-- wp:heading -->
<h2>This is a heading</h2>
<p>This is a paragraph that will be removed without notice for the user</p>
<!-- /wp:heading -->

This block would be considered valid.

@youknowriad youknowriad changed the title Proposal: Check attributes instead of HTML structure for deprecation / validation Improve the Block Validation and Deprecation flows Feb 14, 2019
@youknowriad
Copy link
Contributor

Actually, there's already a better issue with more context, add your thoughts there if needed #7604 I'm interested in improving these flows but this is a hard problem and I haven't seen good proposals so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

4 participants