? ? Success

User tests: Successful: Unsuccessful:

avatar andrepereiradasilva
andrepereiradasilva
24 Jul 2016

Summary of Changes

This PR (alternative to #8540) adds the ability to add more attributes to the script tag using JDocument::addScript(), JDocument::addScriptVersion() and JHtml::script() methods. Also adds the ability to add IE conditional statements.

Also adds the ability to add the same attribs, script version and IE conditional statements when using JHtml::script() method.

Also deprecates MD5SUM and JDocument::addScriptVersion method.

How to test

Please test this in all possible scenarios.
Any problem will get scripts not loading.

  • Use latest staging
  • Apply patch
  • Check backend and frontend are working fine
  • Add external js scripts like to isis/protostar index.php, some examples:
// JDocument B/C tests
$this->addScript('/path/to/external/bcaddScript1.js');
$this->addScript('/path/to/external/bcaddScript2.js', '', true, false);
$this->addScript('/path/to/external/bcaddScript3.js', 'text/javascript', true, true);
$this->addScriptVersion('/path/to/external/bcaddScriptVersion1.js');
$this->addScriptVersion('/path/to/external/bcaddScriptVersion2.js', null, '', true, false);
$this->addScriptVersion('/path/to/external/bcaddScriptVersion3.js', 'version-string', 'text/javascript', true, true);

// JDocument new method tests
$this->addScript('/path/to/external/addScript0.js');
$this->addScript('/path/to/external/addScript1.js', array(), array('id' => 'scriptid'));
$this->addScript('/path/to/external/addScript2.js', array(), array('id' => 'scriptid', 'data-test' => 1));
$this->addScript('/path/to/external/addScript3.js', array(), array('data-attrib' => 'original-value'));
$this->addScript('/path/to/external/addScript4.js', array(), array('data-attrib' => 'final-value'));
$this->addScript('/path/to/external/addScript5.js', array(), array('data-attrib' => array('item1' => 'value1', 'item2' => 'value2')));
$this->addScript('/path/to/external/addScript6.js', array('version' => 'auto'), array('data-attrib' => array('item1' => 'value1', 'item2' => 'value2')));
$this->addScript('/path/to/external/addScript7.js', array('version' => 'version-string'), array('data-attrib' => array('item1' => 'value1', 'item2' => 'value2')));
$this->addScript('/path/to/external/addScript8.js', array('version' => 'auto', 'conditional' => 'lf IE 9'), array('data-attrib' => array('item1' => 'value1', 'item2' => 'value2')));

// JHTML B/C Tests
JHtml::_('script', 'media/system/js/multiselect.js');
JHtml::_('script', 'system/repeatable.js', false, true, false, false, true);

// JHtml new method tests
JHtml::_('script', 'media/com_finder/js/indexer.js', array(), array('data-attrib' => array('item1' => 3, 'item2' => 'value2')));
JHtml::_('script', 'system/progressbar.js', array('relative' => true), array('data-attrib' => array('item1' => 3, 'item2' => 'value2')));
JHtml::_('script', 'system/permissions.js', array('relative' => true, 'version' => 'auto'), array('data-attrib' => array('item1' => 3, 'item2' => 'value2')));
JHtml::_('script', 'system/sendtestmail.js', array('relative' => true, 'version' => 'version-string'), array('async' => 'async', 'defer' => 'defer', 'data-attrib' => array('item1' => 3, 'item2' => 'value2')));
JHtml::_('script', 'system/helpsite.js', array('relative' => true, 'version' => 'version-string', 'conditional' => 'lf IE 9'), array('async' => 'async', 'defer' => 'defer', 'data-attrib' => array('item1' => 3, 'item2' => 'value2')));
  • Check the HTML output and confirm all is fine
  • do the same tests for anything else you can remember
  • Do a code review.

Observations

From a B/C perspective i think there are no issues, but mantainers please check.

PRs depending on this one getting tested & merged

avatar andrepereiradasilva andrepereiradasilva - open - 24 Jul 2016
avatar andrepereiradasilva andrepereiradasilva - change - 24 Jul 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 24 Jul 2016
Category Libraries
avatar joomla-cms-bot joomla-cms-bot - change - 24 Jul 2016
Labels Added: ?
avatar andrepereiradasilva andrepereiradasilva - edited - 24 Jul 2016
avatar andrepereiradasilva andrepereiradasilva - change - 24 Jul 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - change - 24 Jul 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 24 Jul 2016
avatar dgt41
dgt41 - comment - 25 Jul 2016

I am really sorry (because I like this approach) to say that this is not b/c. The reason is that you change _scripts which is public:

    /**
     * Array of linked scripts
     *
     * @var    array
     * @since  11.1
     */
    public $_scripts = array();

avatar brianteeman
brianteeman - comment - 25 Jul 2016

Can you add any attributes? For example I often use the integrity and
crossorigin tags

On 25 July 2016 at 10:01, Dimitri Grammatikogianni <notifications@github.com

wrote:

I am really sorry (because I like this approach) to say that this is not
b/c. The reason is that you change _scripts which is public:

/**
 * Array of linked scripts
 *
 * @var    array
 * @since  11.1
 */
public $_scripts = array();


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#11289 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABPH8dCIkJ7cIlPBYO7agOsIMLKhlgW1ks5qZG12gaJpZM4JTsLM
.

Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/

avatar andrepereiradasilva
andrepereiradasilva - comment - 25 Jul 2016

@dgt41

I am really sorry (because I like this approach) to say that this is not b/c. The reason is that you change _scripts which is public:

And why that is not B/C?
I used the public var, yes. But, notice, the var follows the same principles, so, i can be wrong, but how will this break B/C?
For more info, do a print_r($document->_scripts); in the head renderer before and after the patch.

avatar andrepereiradasilva
andrepereiradasilva - comment - 25 Jul 2016

@brianteeman

Can you add any attributes? For example I often use the integrity and crossorigin tags

Yes, any html attribute to the script tag.

avatar andrepereiradasilva andrepereiradasilva - change - 25 Jul 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 25 Jul 2016
avatar dgt41
dgt41 - comment - 25 Jul 2016

@andrepereiradasilva maybe it's the Monday morning effect. I'll have to do a real comparison of the vars, my imagination seems that fails me at the moment 😄

avatar andrepereiradasilva
andrepereiradasilva - comment - 25 Jul 2016

ok. please check that and test when you have time. thanks.

avatar andrepereiradasilva
andrepereiradasilva - comment - 27 Jul 2016

@mbabker can i ask you to check if from a B/C perspective this is ok?

avatar mbabker
mbabker - comment - 27 Jul 2016

At a glance seems fine. Should add JLog statements though.

avatar andrepereiradasilva
andrepereiradasilva - comment - 27 Jul 2016

ok thank you very much!

avatar andrepereiradasilva andrepereiradasilva - change - 28 Jul 2016
Title
Add attribs to the script tag (alternative to 8540)
Add attribs to the script tag, add version to JHtml script methods and deprecated MD5SUM (alternative to 8540)
avatar andrepereiradasilva andrepereiradasilva - edited - 28 Jul 2016
avatar andrepereiradasilva andrepereiradasilva - change - 28 Jul 2016
Title
Add attribs to the script tag, add version to JHtml script methods and deprecated MD5SUM (alternative to 8540)
Add attribs to the script tag, add version to JHtml script methods and deprecate MD5SUM (alternative to 8540)
avatar andrepereiradasilva andrepereiradasilva - edited - 28 Jul 2016
avatar andrepereiradasilva
andrepereiradasilva - comment - 28 Jul 2016

ok ready for tests

avatar dgt41 dgt41 - test_item - 29 Jul 2016 - Tested successfully
avatar dgt41
dgt41 - comment - 29 Jul 2016

I have tested this item successfully on dad2030

works nicely

    <script src="/media/system/js/progressbar.js" data-attrib="something nice"></script>
    <script src="/media/system/js/permissions.js?5c98b192a5460c43157d762e1e88f0b7" data-attrib="{&quot;item1&quot;:3,&quot;item2&quot;:&quot;value2&quot;}"></script>
    <script src="/media/system/js/sendtestmail.js?version-string" async="async" defer="defer" data-attrib="{&quot;item1&quot;:3,&quot;item2&quot;:&quot;value2&quot;}"></script>
```<hr /><sub>This comment was created with the <a href="https://github.com/joomla/jissues">J!Tracker Application</a> at <a href="https://issues.joomla.org/tracker/joomla-cms/11289">issues.joomla.org/joomla-cms/11289</a>.</sub>
avatar wilsonge
wilsonge - comment - 13 Aug 2016

@andrepereiradasilva Can you rebase this please?

avatar andrepereiradasilva
andrepereiradasilva - comment - 14 Aug 2016

rebased (incorporating now the changes from @mbabker PR #11359)

please test this with attention.

avatar andrepereiradasilva andrepereiradasilva - change - 21 Aug 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 21 Aug 2016
avatar andrepereiradasilva
andrepereiradasilva - comment - 21 Aug 2016

ok, so for supporting also IE continional statements i did the following:

  • Deprecated addScriptVersion
  • Now JHtml::script(), JDocument::addScript have similiar method signatures.
  • Moved the media version adding to JDocument Head Renderer
  • And some other changes

Also all is now controlled by the options array parameter, where, depending on which method you used, you can set everything: conditional, version, relative paths, etc

So there is really no need to use addScript anymore, you can do everything with JHtml::script.

Please test and code review. Also check from a B/C perspective.
PR description is updated.

If this is accepted, similiar changes can be made for the css part.

avatar andrepereiradasilva andrepereiradasilva - change - 21 Aug 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 21 Aug 2016
avatar andrepereiradasilva andrepereiradasilva - change - 21 Aug 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 21 Aug 2016
avatar andrepereiradasilva andrepereiradasilva - edited - 21 Aug 2016
5b090fa 21 Aug 2016 avatar andrepereiradasilva cs
avatar andrepereiradasilva andrepereiradasilva - change - 21 Aug 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 21 Aug 2016
avatar dgt41 dgt41 - test_item - 31 Aug 2016 - Tested successfully
avatar dgt41
dgt41 - comment - 31 Aug 2016

I have tested this item successfully on 5b090fa


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11289.

avatar dgt41
dgt41 - comment - 31 Aug 2016

Can someone test this one?


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11289.

avatar andrepereiradasilva
andrepereiradasilva - comment - 31 Aug 2016

sorry @dgt41 can you mark as tested with success again.
just fixed a minor cs issue b0311fd and udpated the branch to latest staging

avatar dgt41 dgt41 - test_item - 31 Aug 2016 - Tested successfully
avatar dgt41
dgt41 - comment - 31 Aug 2016

I have tested this item successfully on a7410de


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11289.

avatar wilsonge
wilsonge - comment - 4 Sep 2016

This has been merged as part of #11686

avatar wilsonge wilsonge - close - 4 Sep 2016
avatar wilsonge wilsonge - change - 4 Sep 2016
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2016-09-04 23:35:06
Closed_By wilsonge
avatar andrepereiradasilva
andrepereiradasilva - comment - 4 Sep 2016

Where was this merged? @wilsonge ?

avatar wilsonge
wilsonge - comment - 5 Sep 2016

3.7 with the PR mentioned? Or have I misunderstood something?

avatar andrepereiradasilva
andrepereiradasilva - comment - 5 Sep 2016

you misunderstood, the other PR does not contain this PR, it depends on this PR to work.
So as it's is, what you merged in 3.7.x #11686 will not work.

without this PR, JHtml::script and JDocument::addScript does not support adding script with conditional statements (needed in #11686), among the other things in this PR description.

avatar andrepereiradasilva
andrepereiradasilva - comment - 5 Sep 2016

@wilsonge repinging you on this, because the other one you merged in 3.7.x will not work without this, and IMHO this one does not have suficient testing (for the changes it does). please check

avatar wilsonge wilsonge - change - 5 Sep 2016
Status Closed New
Closed_Date 2016-09-04 23:35:03
Closed_By wilsonge
avatar wilsonge wilsonge - change - 5 Sep 2016
Status New Pending
avatar wilsonge wilsonge - reopen - 5 Sep 2016
avatar wilsonge wilsonge - change - 5 Sep 2016
Labels Added: ?
avatar wilsonge
wilsonge - comment - 5 Sep 2016

Thanks somehow missed this this morning

avatar andrepereiradasilva andrepereiradasilva - edited - 5 Sep 2016
avatar andrepereiradasilva andrepereiradasilva - change - 17 Sep 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 17 Sep 2016
avatar andrepereiradasilva
andrepereiradasilva - comment - 17 Sep 2016

can anyone please test this?

avatar andrepereiradasilva
andrepereiradasilva - comment - 17 Sep 2016

thanks michael!

avatar dgt41 dgt41 - test_item - 17 Sep 2016 - Tested successfully
avatar dgt41
dgt41 - comment - 17 Sep 2016

I have tested this item successfully on 1b41718

Still good here


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11289.

avatar andrepereiradasilva
andrepereiradasilva - comment - 17 Sep 2016

thanks @dgt41

avatar wilsonge wilsonge - change - 17 Sep 2016
Labels Added: ?
avatar wilsonge
wilsonge - comment - 17 Sep 2016

Will test tomorrow!

avatar andrepereiradasilva
andrepereiradasilva - comment - 3 Oct 2016

@wilsonge no time to check this?

avatar zero-24
zero-24 - comment - 3 Oct 2016

The two PRs that are depending on this are merged so this here is missing in staging to work correct?

avatar andrepereiradasilva
andrepereiradasilva - comment - 3 Oct 2016

yes, it needs to be merged (after tests) in the 3.7.x branch .

avatar rdeutz
rdeutz - comment - 3 Oct 2016

it is 3.7 so it's needs to be re-based

avatar zero-24 zero-24 - change - 3 Oct 2016
Labels Added: ?
Removed: ?
avatar zero-24
zero-24 - comment - 3 Oct 2016

@andrepereiradasilva i have changed the base can you fix the merge conflichts than?

avatar wilsonge
wilsonge - comment - 3 Oct 2016

I don't think there are any merge conflicts? And yes will try and find time tonight! Sorry really busy with work at the moment.

avatar zero-24
zero-24 - comment - 3 Oct 2016
avatar andrepereiradasilva
andrepereiradasilva - comment - 3 Oct 2016

ok conflicts fixed, should be fine now. please test

avatar rdeutz
rdeutz - comment - 6 Oct 2016

Could we have one more successful test before this get's merged, please.

avatar zero-24
zero-24 - comment - 8 Oct 2016

Looks good here but please confirm that:

data-attrib="{&quot;item1&quot;:&quot;value1&quot;,&quot;item2&quot;:&quot;value2&quot;}"></script>

Is correct, i mean the &quot; 's ;)

avatar mbabker
mbabker - comment - 8 Oct 2016

Well, it has to be encoded, otherwise it would be data-attrib="{"item1":"value1","item2":"value2"}" and that would result in massively broken HTML.

avatar dgt41
dgt41 - comment - 8 Oct 2016

@zero-24 it's fine, as that is valid javascript notation

avatar zero-24 zero-24 - test_item - 8 Oct 2016 - Tested successfully
avatar zero-24
zero-24 - comment - 8 Oct 2016

I have tested this item successfully on 12f4c4b

Thnaks I just want to be sure as i'm not a JS pro like you 😄 👍


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/11289.

avatar dgt41 dgt41 - test_item - 8 Oct 2016 - Tested successfully
avatar dgt41
dgt41 - comment - 8 Oct 2016

I have tested this item successfully on 12f4c4b


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/11289.

avatar dgt41 dgt41 - change - 8 Oct 2016
Status Pending Ready to Commit
avatar dgt41
dgt41 - comment - 8 Oct 2016

@rdeutz press the button!

avatar joomla-cms-bot joomla-cms-bot - change - 8 Oct 2016
Labels Added: ?
avatar rdeutz rdeutz - change - 9 Oct 2016
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2016-10-09 07:40:50
Closed_By rdeutz
avatar rdeutz rdeutz - close - 9 Oct 2016
avatar rdeutz rdeutz - merge - 9 Oct 2016
avatar rdeutz rdeutz - close - 9 Oct 2016
avatar joomla-cms-bot joomla-cms-bot - close - 9 Oct 2016
avatar rdeutz rdeutz - change - 9 Oct 2016
Labels Removed: ?
avatar brianteeman
brianteeman - comment - 9 Oct 2016

Removed RTC label

avatar joomla-cms-bot joomla-cms-bot - change - 9 Oct 2016
Labels Removed: ?

Add a Comment

Login with GitHub to post a comment