Comments (8)
If I am right, it should return the element itself, because the width has a fixed definition
If the element has a percentage width, the dimension is not fixed in all cases. In the following example, the percentage width is not fixed:
<div style="width: 1000px;">
<div style="float: left;">
<div style="width: 50%;">
<div>My Element</div>
</div>
</div>
</div>
But with a small change (removing the float
from the parent) it becomes a fixed width and thus a valid container:
<div style="width: 1000px;">
<div style="float: none;">
<div style="width: 50%;">
<div>My Element</div>
</div>
</div>
</div>
So in the first case the outermost <div>
should get returned by getContainer()
and in the second case the <div>
with the percentage width should get returned.
Does this explanation help? Or do you have an example code where it doesn’t work as intended?
from cq-prolyfill.
Hallo,
thank you for your comment. It made it more clear. Nevertheless, that is not the problem.
I was digging a little bit deeper and recognized, that the problem comes from the stylesheet parsing.
In my css, I include other css files. In this case, the buildStyleCacheFromRules() function fails, because the "if (rules[i].type === 1)" is false (rules[i].type is 3) and the "else if (rules[i].cssRules)" is undefined.
In this case (rules[i].type === 3), the css rules are in the object rules[i].styleSheet.cssRules.
So if we add the following case to the if, it should work:
else if (rules[i].type === 3 && rules[i].styleSheet.cssRules) { buildStyleCacheFromRules(rules[i].styleSheet.cssRules); }
I've just tested it and it works.
And I created a codepen to showcase the problem: https://codepen.io/anon/pen/wyWbWm
What do you think?
from cq-prolyfill.
This sounds like the issue #49.
This was fixed in 579d039 in the development branch and will be fixed with the next release.
from cq-prolyfill.
Yes, it's the same issue. I've fixed it a little bit different, because imported stylesheets can contain imported stylesheets again. I've just created a pull request, that - at least I think so - handles all cases and is very simple.
Thank you, best regards, Pascal
from cq-prolyfill.
Did you test the changes from 579d039 ?
Nested imports should work there too.
from cq-prolyfill.
Ahh, sorry. I missed something. You are talking about the buildStyleCacheFromRules()
function, not about parseRules()
.
You are right, that needs to be fixed too. I close this issue in favor of your pull request #51.
from cq-prolyfill.
Hello,
I just recognized a problem with my fix with Firefox. Firefox has a bug that restricts js access to css imported with @import
("SecurityError: The operation is insecure error").
I just updated my fix and will start a new pull request.
from cq-prolyfill.
Great. But you can push more commits to your existing Fix-@import-stylesheet-parsing
branch. This way you don’t have to create a new pull request.
from cq-prolyfill.
Related Issues (20)
- Does cq-prolyfill inlined my style? HOT 1
- Minified cq-prolyfill.js file with gulp-concat doesn't work HOT 1
- Add stylesheet URL whitelist option
- Idea: ability to pre-parse CSS at build time
- Try to remove or reduce the FOUC problem HOT 10
- Add support for attribute selector based queries HOT 1
- Don’t run the script multiple times in the same frame HOT 1
- Use ResizeObserver HOT 8
- Use CSS Houdini (CSS Typed OM Level 1) to get the computed style HOT 1
- Check for max- and min-width and -height values
- In Safari with disabled cache container queries doesn't apply on first script load HOT 4
- Production as default, development/demo configurable HOT 1
- Improve getContainer, remove duplicated calls to getComputedStyle
- Raise minimum supported browser versions HOT 3
- Handling CSS Import Rule
- mixins.scss missing from package
- [IE11] Wrong Result if used with CSS Grid Layout HOT 2
- Don't work in Chrome 112 HOT 2
- Not working in Chrome anymore HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cq-prolyfill.