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 logic for determining when to do fallback refresh for post field partials #335

Merged
merged 2 commits into from Dec 21, 2016

Conversation

Projects
None yet
1 participant
@westonruter
Contributor

westonruter commented Dec 18, 2016

The changes are part of some experimentation I'm doing (along with JS Widgets) to enable Customize Posts to directly mutate Backbone models created from the WP-API JS client, with the aim of demonstrating patterns for how Customize Posts can be used to manage themes that are rendered purely with JS templates. As part of this I found that we need the partials to be smarter about when they decide that they need to do the fallback behavior of a full refresh. I've introduced the idea of a “fallback dependent selector” which is used to do a test on the document to see whether or not a refresh is warranted. Namely, this selector is intended to normally match the body class or post class that would reference a given post so that if neither the current singular preview or the current archive loop mention a given post, then the fallback refresh behavior should be skipped because the element wouldn't be appearing on the page anyway. As such, this should cut down on some needless full refreshes.

  • Refactor body_selector, singular_only, and archive_only into fallback_dependent_selector
  • Allows partial selectors to have make use of post ID placeholders in the form of %d.
  • Selective refresh fallback behavior is changed to be prevented when changing a post that isn't referenced on a given template (via body_class or post_class).
  • Nevertheless, the selective refresh requests still are made so that the REST API Backbone models have the opportunity to update their rendered properties.
  • Adds initial support for Twenty Seventeen.
Refactor body_selector, singular_only, and archive_only into fallback…
…_dependent_selector

* Allows partial selectors to have make use of post ID placeholders in the form of %d.
* Selective refresh fallback behavior is changed to be prevented when changing a post that isn't referenced on a given template (via body_class or post_class).
* Nevertheless, the selective refresh requests still are made so that the REST API Backbone models have the opportunity to update their rendered properties.
* Adds initial support for Twenty Seventeen.

@westonruter westonruter requested a review from valendesigns Dec 18, 2016

@westonruter westonruter added this to the 0.8.5 milestone Dec 18, 2016

@westonruter westonruter requested review from PatelUtkarsh and sayedtaqui Dec 18, 2016

@westonruter westonruter merged commit 369f831 into feature/rest-api-model-integration Dec 21, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@westonruter

This comment has been minimized.

Show comment
Hide comment
@westonruter

westonruter Dec 21, 2016

Contributor

Please follow up on #333

Contributor

westonruter commented Dec 21, 2016

Please follow up on #333

@westonruter westonruter deleted the feature/partial-schema-refactor branch Dec 21, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment