Repository navigation
feat(dev): add css helper function - #42148
Conversation
|
Re-running Actions, because of this error: remote: Internal Server Error.
remote:
Error: fatal: unable to access 'https://github.com/freeCodeCamp/freeCodeCamp/': The requested URL returned error: 500
The process '/usr/bin/git' failed with exit code 128 |
|
Looks like they have an ongoing incident: https://www.githubstatus.com/incidents/zbpwygxwb3gw |
MDN says |
I have not tested outside of Chromium-based browsers. This is what I meant by whether they follow spec or not. Ideally, it should allow the tests to follow the exact input of the CSS value (provided it is valid CSS), which means this would solve the issue of testing against values which have gone through compilation (e.g. I would appreciate this being tested on Safari, before adoption. |
|
If the spec is respected by all modern browsers, that's awesome - it should mean we don't need to worry about CSS parsers. Do you know how media queries are handled? |
cssRules: CSSRuleList
0: CSSStyleRule {selectorText: "body", style: CSSStyleDeclaration, styleMap: StylePropertyMap, type: 1, cssText: "body {
background: black; color: cornsilk; }", …}
1: CSSMediaRule
conditionText: "(max-width: 996px)"
cssRules: CSSRuleList {0: CSSStyleRule, length: 1}
cssText: "@media (max-width: 996px) {\n p { border: 1px solid black; }\n}"
media: MediaList {0: "(max-width: 996px)", length: 1, mediaText: "(max-width: 996px)"}
parentRule: null
parentStyleSheet: CSSStyleSheet {ownerRule: null, cssRules: CSSRuleList, rules: CSSRuleList, type: "text/css", href:
"http://localhost:1234/styles.8986bff4.css", …}
type: 4
__proto__: CSSMediaRule
length: 2
__proto__: CSSRuleList
disabled: false@ojeytonwilliams Good catch. I will add some logic to check for |
It looks like it's not an array, exactly, so it probably doesn't have all of Array's methods. |
|
@ShaunSHamilton did you make the bot mad 😛 |
Umm.... I did an "oops" - Git betrayed me |
ShaunSHamilton
left a comment
There was a problem hiding this comment.
Forgive the mess. Also, I could not leave the example file without the small changes - OCD acting up.
|
@ShaunSHamilton It doesn't seem strictly necessary, but it's not that onerous to add it. Without fully understanding why the rule exists in the first place, I'd rather not just rip it out. |
|
The last 2 tests will keep failing because JSDOM does not implement
So, shall I change the test? Or, block this until I can get a PR opened on CSSOM? |
There hasn't been any activity on that project in like 6 months. Can we inject that property ourselves in the test environment? |
|
Hmm I don't see a real clean way to do that - might be worth yoinking the test until/if the lib is updated. |
@nhcarrigan We can. The exact value exists on the MediaList ( |
naomi-lgbt
left a comment
There was a problem hiding this comment.
I've played with this a bit, and it is leaps and bounds above the regex approach.
Not 100% sure if it covers all of our use-cases, but as it stands now it's a significant improvement. Happy to merge.
ojeytonwilliams
left a comment
There was a problem hiding this comment.
Nitpicking about test structure, mostly.
It looks good, though, I think this is basically done.
Co-authored-by: Oliver Eyton-Williams <[email protected]>
Checklist:
Update index.md)mainbranch of freeCodeCamp.This PR adds a small css helper function for testing the curriculum. Example usage:
Some notes about the reliability of this function:
document.styleSheets[1].cssRulesreturned an array - I do not know why it no longer does, but, honestly, it worked for a few tests, then changed to needing theObject.values. We might need to add a check forisArrayPS: I am also working on an HTML helper function, because I am allergic to jQuery, and vanilla JS has so many DOM methods we could use better