-
-
Notifications
You must be signed in to change notification settings - Fork 25
Implement universal selector handling in getStyle #561
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
0760191
0284bd9
17d935e
02d59cd
d7fd709
044a0e9
1e1aab9
efcdc21
f55e3ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the changes to this file are only some empty lines added, please revert |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,10 +4,13 @@ import React from "react"; | |
| import ReactDOM from "react-dom/client"; | ||
|
|
||
| import cssTestValues from "./__fixtures__/curriculum-helper-css"; | ||
| import { cssString } from "./__fixtures__/curriculum-helper-css"; | ||
|
||
| import htmlTestValues from "./__fixtures__/curriculum-helpers-html"; | ||
| import jsTestValues from "./__fixtures__/curriculum-helpers-javascript"; | ||
| import whiteSpaceTestValues from "./__fixtures__/curriculum-helpers-remove-white-space"; | ||
|
|
||
| import * as helper from "./../helpers/lib/index"; | ||
| import { CSSHelp } from "./../helpers/lib/index"; | ||
|
||
|
|
||
| const { stringWithWhiteSpaceChars, stringWithWhiteSpaceCharsRemoved } = | ||
| whiteSpaceTestValues; | ||
|
|
@@ -862,3 +865,32 @@ describe("permutateRegex", () => { | |
| expect(regex.test(`'b" === a`)).toBe(false); | ||
| }); | ||
| }); | ||
| describe("CSSHelp – universal selector handling", () => { | ||
| beforeEach(() => { | ||
| const style = document.createElement("style"); | ||
| style.className = "fcc-injected-styles"; | ||
| style.textContent = cssString; | ||
| document.head.appendChild(style); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| document.head.innerHTML = ""; | ||
| }); | ||
|
|
||
| it("should return styles for selectors containing a universal selector", () => { | ||
| const cssHelp = new CSSHelp(document); | ||
|
|
||
| const style = cssHelp.getStyle('span[class~="one"] *:first-of-type'); | ||
|
|
||
| expect(style).not.toBeNull(); | ||
| expect(style?.getPropVal("border-color")).toBe("#d61"); | ||
| }); | ||
|
|
||
| it("should return null for selectors that do not exist", () => { | ||
| const cssHelp = new CSSHelp(document); | ||
|
|
||
| const style = cssHelp.getStyle("div.non-existent-selector"); | ||
|
|
||
| expect(style).toBeNull(); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please do not change the current existing strings, the current tests are based on these and changing them could interfere, if you need new css, create a new string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thankyou for correcting me I will ensure I follow each command.I appreciate the community support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the change to the existing string is still here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have a check I fixed