Labels |
Added:
?
|
Status | New | ⇒ | Discussion |
Category | ⇒ | JavaScript |
Thanks for the pointer. I can fix that on the train to the presentation
or maybe not
A quick search shows these three variations - is there some logic behind the differences?
HTMLHelper::_('webcomponent', 'vendor/joomla-custom-elements/joomla-alert.min.js', ['relative' => true, 'version' => 'auto']);
HTMLHelper::_('webcomponent', 'vendor/joomla-custom-elements/joomla-alert.min.js', ['relative' => true, 'version' => 'auto', 'detectBrowser' => false, 'detectDebug' => false]);
HTMLHelper::_('webcomponent', 'system/webcomponents/joomla-field-media.min.js', ['relative' => true, 'version' => 'auto', 'detectBrowser' => false, 'detectDebug' => true]);
Tha last one should be the norm...
Would it make sense to add those as default values to the HtmlHelper method? If not needed it could be explicitely disabled instead of us having to explicitely add it everywhere.
Would save a massive search and replace and ofc no guarantee it wouldn't happen again
On a fast glance there is actually a default defineed. It's just false
. If we change that to true
we could save quite a bit of code. Also the relative
and detectBrowser
would already be covered.
See
joomla-cms/libraries/src/HTML/HTMLHelper.php
Lines 843 to 845 in 1daaaac
Is detectDebug the boolean that will ensure the uncompressed version of the file is loaded when debug mode is enabled?
yes
Why does that need to be a function arguement?
it's there for B/C
It has use in some edge cases. I have extensions where I'm pulling a vendor CSS or JS file and not including both a minified and unminified version of it, so I can tell Joomla to save a few CPU cycles and skip deciding if debug mode is enabled and trying to scan the filesystem for variants that will never exist (same for the detectBrowser option).
it's there for B/C
B/C for a method which is completely new in 4.0.0? Probably not.
In the other similar methods for scripts and stylesheets, detectDebug
already defauls to true, so I'd say it's save to change that behavior for the new method so it follows the other behaviors.
See #21617
@Bakual if you are about to make this change for the webcomponents why don't you also change it for script and stylesheet, eg make the relative true, the version auto, the detectBrowser false and the detectDebug true as default for all of them?
That will save as a lot of repeated flags and still allow users to use the other settings if they want to.
Sensible defaults make sense to me
From what I saw, detectBrowser
defaults already to false
in all those methods.
version
defaults to empty (false) in all cases. So that's consistent as well.
The only thing different is the relative
one, and that one I didn't change in the other methods because it would be a B/C break for those existing methods.
I wanted to keep my PR as a no-brainer, changing one simple thing which doesn't break anything
Labels |
Added:
J4 Issue
|
Build | staging | ⇒ | 4.0-dev |
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-09-13 08:52:19 |
Closed_By | ⇒ | brianteeman |
@brianteeman check for example rules.php under layouts/joomla/form:
there is a missing flag
'detectDebug' => true