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

Fixes #651 - Serialize only input and state on top-level server-rendered UI components #672

Merged
merged 18 commits into from Apr 18, 2017

Conversation

patrick-steele-idem
Copy link
Contributor

@patrick-steele-idem patrick-steele-idem commented Apr 18, 2017

For context, please see Issue #651 - Proposal: serialize only input and state on top-level server-rendered UI components #651

This Pull Request introduces some important changes to Marko:

  • Only the data (including state, input and properties added to the UI component instance) for top-level UI components is serialized down to the browser (previously, this data was serialized for every UI component rendered on the server)
  • When the page boots in the browser, the top-level UI components are "partially" re-rendered using the serialized data
  • As part of the partial re-render, the rendering logic executes but the DOM is not updated and no VDOM nodes are actually created (the partial re-render is only used to mount nested UI components)
  • NOTE: If a top-level UI component is "split" (that is, rendering logic is not sent down to the browser) then the old behavior will be continued
  • The out.global object is not serialized, but specify properties can be whitelisted to be serialized. For example, to have the out.global.apiKey and the out.global.locale properties serialized you would do the following:
template.render({
        $global: {
            serializedGlobals: {
                apiKey: true,
                locale: true
            }
        }
    }, res);

There is a chance that this might break existing apps. To revert back to the old behavior on a page-by-page basis you can do the following:

<marko no-browser-rerender />

<html>
  ...
</html>

@coveralls
Copy link

@coveralls coveralls commented Apr 18, 2017

Coverage Status

Coverage increased (+0.03%) to 90.296% when pulling 6ff3706 on issue-651 into 9604a85 on master.

@patrick-steele-idem patrick-steele-idem merged commit 845c177 into master Apr 18, 2017
3 checks passed
@DylanPiercey DylanPiercey deleted the issue-651 branch Mar 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants