eeditiones / tei-publisher-components

Web components used by TEI Publisher and apps generated by it
https://cdn.tei-publisher.com/
GNU General Public License v3.0
18 stars 14 forks source link

fix(pb-i18n): fix concurrency issue #19

Closed wolfgangmm closed 4 years ago

wolfgangmm commented 4 years ago

pb-page sends a pb-i18n-update event when translations become available. This event was used to set the singleton translation function for the lit-html parts as well as trigger pb-i18n to update. However, the latter requires that the translation function is already set, and because there is no guarantee in which sequence event listeners are processed, the function may still have been undefined when the event reached pb-i18n. Solution: pb-page now explicitely sets the translation function singleton before it triggers the event. This way - whoever receives the event next - can be sure there's a translation function already set.

The PR also addresses an issue with pb-i18n translations being used in the options passed to pb-select: paper-dropdown-menu uses the text content of each item to display the current selection. But since pb-i18n kept the translated text in its shadow DOM, the light DOM text content was always the original, untranslated value. Solution: change pb-i18n to not use shadow DOM. It is unnecessary for an element only containing text.

JoernT commented 4 years ago

wow, yes - i kind of felt the shadowDom issue but couldn't really put my fingers on it. That's one reason to think twice before using shadowDom - but because it's there by default doesn't mean you should use it for each and every component.

github-actions[bot] commented 4 years ago

:tada: This PR is included in version 1.2.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: