Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mod_Wrapper multiple instances #19136

Merged
merged 5 commits into from
Jan 16, 2018
Merged

Mod_Wrapper multiple instances #19136

merged 5 commits into from
Jan 16, 2018

Conversation

brianteeman
Copy link
Contributor

@brianteeman brianteeman commented Dec 22, 2017

Pull Request for Issue #17425

This is a PARTIAL fix. It addresses the issue of the unique id for each occurrence of a wrapper module but as noted in the original issue the JS is broken as well

It looks to me that we can change the selector to the following

var iframe = document.querySelectorAll('*[id^="blockrandom"]');

but there are still issues and I am NOT a js guru (pinging @dgt41 )

Summary of Changes

Testing Instructions

Expected result

Actual result

Documentation Changes Required

@Quy
Copy link
Contributor

Quy commented Dec 22, 2017

I have tested this item ✅ successfully on 0f908f0


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

@dgrammatiko
Copy link
Contributor

Just turn that Id to a class to solve the multiple instances problem (it’s a b/c break by the way).
About the chrome error: it’s expected unless you properly set the allowed scripts in your site. There is nothing to fix here

@brianteeman
Copy link
Contributor Author

Sorry I don't understand you?

@dgrammatiko
Copy link
Contributor

Either your approach here or a class driven solution is b/c break! Think that someone got an override then either solution will break the overrides...

@brianteeman
Copy link
Contributor Author

turning the id to a class would be an a11y fail as every iframe has to have a unique id which was the whole point of the pr

@dgrammatiko
Copy link
Contributor

@brianteeman can you please add also the js part (the code in the desc is fine)

@brianteeman
Copy link
Contributor Author

js added

@C-Lodder
Copy link
Member

You can still have an ID on the iframe. Just add a class too and target the class in the JS as opposed to the ID

@Sophist-UK
Copy link
Contributor

Sophist-UK commented Jan 8, 2018

After applying this fix I get:

iframe-height.js:5 Uncaught TypeError: Cannot use 'in' operator to search for 'contentDocument' in null
    at iFrameHeight (iframe-height.js:5)
    at HTMLIFrameElement.onload ((index):809)

Page has two iframes - one within com_wrapper, and one inserted into a module by a different plugin.

See #19337 for environment.

@brianteeman
Copy link
Contributor Author

iirc the code i wrote here only addresses multiple instances of the wrapper module. your bug sounds unrelated

@@ -1,7 +1,7 @@
function iFrameHeight()
{
var height = 0;
var iframe = document.getElementById('blockrandom');
var iframe = document.querySelectorAll('*[id^="blockrandom"]');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove spaces at the end of the line.

@Sophist-UK
Copy link
Contributor

IMO the call to iframeHeight should be made with the ID as a parameter so that the JS can find the absolutely correct iframe.

@Sophist-UK
Copy link
Contributor

iirc the code i wrote here only addresses multiple instances of the wrapper module. your bug sounds unrelated

No - the error message I reported after trying this fix only appears with this fix and is unrelated to the cross-domain issue I have reported separately.

@Fedik
Copy link
Member

Fedik commented Jan 9, 2018

iirc the code i wrote here only addresses multiple instances of the wrapper module. your bug sounds unrelated

it is relevant 😉
after your changes var iframe contain multiple iframe element instead of 1, but whole code expect 1 element.
The code need more changes to support multiple instances.

@Fedik
Copy link
Member

Fedik commented Jan 9, 2018

@brianteeman I am not tested, but this should work: ignore it

function iFrameHeight()
{
    var iframe, doc, 
        height  = 0,
        isAll   = !!document.all,
        iframes = document.querySelectorAll('iframe[id^="blockrandom"]');

    for (var i = 0, l = iframes.length; i < l; i++) {
        iframe = iframes[i];
        doc    = 'contentDocument' in iframe ? iframe.contentDocument : iframe.contentWindow.document;
        height = parseInt(doc.body.scrollHeight);

        if (!isAll)
        {
            iframe.style.height = height + 60 + 'px';
        }
        else
        {
            document.all[iframe.id].style.height = height + 20 + 'px';
        }
    }
}

@Sophist-UK
Copy link
Contributor

Sophist-UK commented Jan 9, 2018

The problem with this code is that it will run on every iframe every time any iframe finishes loading.

As stated previously IMO the code should call iFrameHeight with the id as a parameter iframeHeight(id) and the code should then read:

function iFrameHeight(id)
{
    var height = 0;
    var iframe = document.getElementById('blockrandom-' + id);
    var doc    = 'contentDocument' in iframe ? iframe.contentDocument : iframe.contentWindow.document;

    if (!document.all)
    {
        height = doc.body.scrollHeight;
        iframe.style.height = parseInt(height) + 60 + 'px';
    }
    else if (document.all)
    {
        height = doc.body.scrollHeight;
        document.all.blockrandom.style.height = parseInt(height) + 20 + 'px';
    }
}

@Fedik
Copy link
Member

Fedik commented Jan 9, 2018

okay, I see,
then it can be even easier

@Fedik
Copy link
Member

Fedik commented Jan 9, 2018

@brianteeman check brianteeman#67

@brianteeman
Copy link
Contributor Author

@Sophist-UK you asked for changes, changes have been made so please test

@Sophist-UK
Copy link
Contributor

I have tested this - still getting the x-domain console error which is to be expected, but aside from that it seems to work.

@Quy
Copy link
Contributor

Quy commented Jan 16, 2018

@Sophist-UK Please mark your test result here: https://issues.joomla.org/tracker/joomla-cms/19136

@Sophist-UK
Copy link
Contributor

I have tested this item ✅ successfully on d81bea8.


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

@Quy
Copy link
Contributor

Quy commented Jan 16, 2018

I have tested this item ✅ successfully on d81bea8


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

@Quy
Copy link
Contributor

Quy commented Jan 16, 2018

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jan 16, 2018
@brianteeman brianteeman added this to the Joomla 3.8.4 milestone Jan 16, 2018
@mbabker mbabker merged commit 0bf1b3b into joomla:staging Jan 16, 2018
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Jan 16, 2018
@brianteeman
Copy link
Contributor Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants