[4.0] Showon init only once, public method Joomla.Showon.initialise()#32069
Merged
wilsonge merged 3 commits intojoomla:4.0-devfrom Jan 27, 2021
Merged
[4.0] Showon init only once, public method Joomla.Showon.initialise()#32069wilsonge merged 3 commits intojoomla:4.0-devfrom
wilsonge merged 3 commits intojoomla:4.0-devfrom
Conversation
dgrammatiko
suggested changes
Jan 17, 2021
| // @todo refactor this, dry | ||
| this.showonFields.forEach((field) => { | ||
| // Set up only once | ||
| if (field.hasAttribute('data-showon-initialised')) { |
Contributor
There was a problem hiding this comment.
Can we change this to field.dataset.hasOwnProperty('showonInitialised')
Member
Author
There was a problem hiding this comment.
in the end it the same, but use the attribute is more clear for "visual debuging" ;)
dgrammatiko
reviewed
Jan 17, 2021
| if (field.hasAttribute('data-showon-initialised')) { | ||
| return; | ||
| } | ||
| field.setAttribute('data-showon-initialised', ''); |
Contributor
There was a problem hiding this comment.
field.dataset.showonInitialised = '';
Contributor
|
I have tested this item ✅ successfully on 1e2b0dd This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32069. |
Member
|
@Fedik please fix cs https://ci.joomla.org/joomla/joomla-cms/39281 |
Member
Author
|
done |
Contributor
|
I have tested this item ✅ successfully on e28aae0 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32069. |
Contributor
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary of Changes
Same as #32061
The code make sure that showon initialised only once, no mater how often Joomla.Showon.initilise was called.
Also add public
Joomla.Showon.initilise(to be in sync with 3.10)Testing Instructions
Apply path, run
npm installMake sure
showonstill works.Example, go to global config change "Debug Language" on/off, should downup/hides "Language Display" field.
Also the field "Language Display" will have extra attribute
data-showon-initialisedActual result BEFORE applying this Pull Request
showon works,
the showon field do not have
data-showon-initialisedExpected result AFTER applying this Pull Request
showon works,
the showon field do have
data-showon-initialisedattribute