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

[metal-dom] Styles are not loaded in order in IE11 #383

Open
antonio-ortega opened this issue Jun 18, 2018 · 6 comments
Open

[metal-dom] Styles are not loaded in order in IE11 #383

antonio-ortega opened this issue Jun 18, 2018 · 6 comments

Comments

@antonio-ortega
Copy link

When using globalEvalStyles.runStylesInElement to load several CSS files and inline styles in IE11 they are not loaded in order. If you are loading a very large CSS file, and just after that some inline styles, these ones would be overriden. This is happening only in IE11.

This is happening only for styles and not for scripts, because in scripts we load them orderly, where next file is called from previous file's callback.

While for styles they are loaded inside a for loop without waiting till previous styles are completed loaded, as you can see here.

In order to find a solution, I tried a similar code in globEvalStyles but 'load' event was not being fired by IE11 for link elements, so the callback to load next styles' file was not loaded.

Thanks,

@jbalsas
Copy link
Contributor

jbalsas commented Jun 19, 2018

Hey @diegonvs, @matuzalemsteles, could you guys take a look here?

@matuzalemsteles
Copy link
Contributor

I'll take a look at this with @diegonvs this afternoon.

matuzalemsteles added a commit to matuzalemsteles/metal.js that referenced this issue Jul 20, 2018
@diegonvs
Copy link
Contributor

diegonvs commented Aug 9, 2018

Just for information: As filled internally, there is a problem on Senna. A fix need be applied into Senna.

@yuchi
Copy link
Contributor

yuchi commented Aug 20, 2018

/cc @GianBe

@jbalsas
Copy link
Contributor

jbalsas commented Aug 20, 2018

Just for additional reference, this is looking more and more as an IE11 issue.

Running this snippet of code in a navigated page in IE11 will show different document.styleSheets ordering:

s = document.createElement('style');
s.type = 'text/css';
s.textContent = '#footer { background-color: pink; }';
document.head.appendChild(s);

for(var i=0; i<document.styleSheets.length; i++) {
    var styleSheet = document.styleSheets[i];
    var cssText = styleSheet.owningElement.href; 

    if (!cssText) {
        cssText = styleSheet.cssText;
    }
    
    console.log(i, cssText);
}

var docElem = document.documentElement;
var docElemNext = docElem.nextSibling;

document.removeChild(docElem); // this will clear document.styleSheets
document.insertBefore(docElem, docElemNext);

for(var i=0; i<document.styleSheets.length; i++) {
    var styleSheet = document.styleSheets[i];
    var cssText = styleSheet.owningElement.href; 

    if (!cssText) {
        cssText = styleSheet.cssText;
    }
    
    console.log(i, cssText);
}

It looks like IE11 does not correctly recompute css precedence under some conditions, independently on wether the resources are added in the right order and with proper timing.

@duracell80
Copy link

duracell80 commented Sep 24, 2019

Wouldn't this also cause issues for css placed in style tags in content fragments in DXP 7.2? If I'm following correctly IE is applying mobile device breakpoints to a desktop page?

That's kinda a big deal, that would lead to display corruption.

I've been seeing these kinds of display issues when navigating pages in IE. I hate IE too, but it's still the dominate browser in enterprise. Just turn senna off for IE.

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

No branches or pull requests

6 participants