CSS-Used-ChromeExt icon indicating copy to clipboard operation
CSS-Used-ChromeExt copied to clipboard

FAQ: get the css from parent defined

Open rowthan opened this issue 2 years ago • 1 comments

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 avatar Aug 18 '23 10:08 rowthan

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

rowthan avatar Aug 18 '23 10:08 rowthan