mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Adds syncInitialRender setting
This separates the behavior from `legacyOptimizations`. Performs synchronous initial rendering under ShadyDOM when this flag is set.
This commit is contained in:
@@ -9,7 +9,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
*/
|
||||
import '../utils/boot.js';
|
||||
|
||||
import { rootPath, strictTemplatePolicy, allowTemplateFromDomModule, legacyOptimizations } from '../utils/settings.js';
|
||||
import { rootPath, strictTemplatePolicy, allowTemplateFromDomModule, legacyOptimizations, syncInitialRender } from '../utils/settings.js';
|
||||
import { dedupingMixin } from '../utils/mixin.js';
|
||||
import { stylesFromTemplate, stylesFromModuleImports } from '../utils/style-gather.js';
|
||||
import { pathFromUrl, resolveCss, resolveUrl } from '../utils/resolve-url.js';
|
||||
@@ -659,7 +659,7 @@ export const ElementMixin = dedupingMixin(base => {
|
||||
n.attachShadow({mode: 'open'});
|
||||
}
|
||||
n.shadowRoot.appendChild(dom);
|
||||
if (legacyOptimizations && window.ShadyDOM) {
|
||||
if (syncInitialRender && window.ShadyDOM) {
|
||||
ShadyDOM.flushInitial(n.shadowRoot);
|
||||
}
|
||||
return n.shadowRoot;
|
||||
|
||||
@@ -140,4 +140,22 @@ export let legacyOptimizations = false;
|
||||
*/
|
||||
export const setLegacyOptimizations = function(useLegacyOptimizations) {
|
||||
legacyOptimizations = useLegacyOptimizations;
|
||||
};
|
||||
|
||||
/**
|
||||
* Setting to perform initial rendering synchronously when running under ShadyDOM.
|
||||
* This matches the behavior of Polymer 1.
|
||||
*/
|
||||
export let syncInitialRender = false;
|
||||
|
||||
/**
|
||||
* Sets `syncInitialRender` globally for all elements to enable synchronous
|
||||
* initial rendering.
|
||||
*
|
||||
* @param {boolean} useSyncInitialRender enable or disable synchronous initial
|
||||
* rendering globally.
|
||||
* @return {void}
|
||||
*/
|
||||
export const setSyncInitialRender = function(useSyncInitialRender) {
|
||||
syncInitialRender = useSyncInitialRender;
|
||||
};
|
||||
Reference in New Issue
Block a user