feat(framework): Add dynamic language change and on-demand rerendering #1746
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.
You can test this change with the new
RTL.html
page inmain
.This change adds:
RenderScheduler
which allows to re-render all components on the page, only thertlAware
ones, only thelanguageAware
ones, or both.setLanguage
method in the configurationapplyDirection
method inbase/scr/locale
which re-renders rtl-aware componentsIn order to be able to determine what to re-render,
RenderScheduler
needs to keep aSet
of all active components on the page:onEnterDOM
onExitDOM
The reason for this logic is that we don't want to keep references to elements forever, as that would prevent garbage collection. Instead we only re-render active elements.
In order to be able to determine which components are rtl-aware, we track their calls to the
effectiveDir
function. There is a small new registry for that purpose.Additional changes:
setToArray
added because of IE supportfireEvent
inEventProvider.js
now returns an array of the results of all registered event listeners. This is very handy if these listeners do async work, and you want to wait for this work, as we do here inLanguage.js
.