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

FAQ: get the css from parent defined #56

Open
rowthan opened this issue Aug 18, 2023 · 1 comment
Open

FAQ: get the css from parent defined #56

rowthan opened this issue Aug 18, 2023 · 1 comment

Comments

@rowthan
Copy link

rowthan commented Aug 18, 2023

about FAQ 2. css will be ignored when defined with parent selector.
like

<div id="parent"><div class="child"></div></div>

#parent .child{
  background: red;
}

if we choose the child element as $0 , the result is empty.

i have a method to solve this problem:

firstly, checking whether the last selector is matched. matched in this case .child

$0.matched('.child') // true

secondly, checking the parent selector is the parent of the target:

const parentSelector = '#parent';
const parentElement = document.querySelector(parentSelector);
const isMatched = parentElement.contain($0); 

we can add a root node as the wrapper of $0

<div id="the-root-for-wrapper-result"><div class="child"></div></div>
#the-root-for-wrapper-result  .child{
   background: red;
}
@rowthan
Copy link
Author

rowthan commented Aug 18, 2023

check is it work please? i would like make pull request if you accept this idea.

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

1 participant