W3C home > Mailing lists > Public > www-style@w3.org > July 2008

Re: Parent Combinator / Parent pseudo-class

From: Francois Remy <fremycompany_pub@yahoo.fr>
Date: Thu, 24 Jul 2008 00:08:39 +0200
Message-ID: <E5D26573EA2B4E9A85749AEE1A5CEE3A@FremyCompany1>
To: "Boris Zbarsky" <bzbarsky@MIT.EDU>
Cc: "www-style list" <www-style@w3.org>

Sorry but it's not true... If you talk about the fact about the fact I 
abonnate myself on mouseover events, please give my a solution that can do I 
receive a JScript event any time something change for the specified element 
? It's not possible in JScript. So, yes, I must abonnate myself on the event 
manually. But there's no other possibility.... Yes, there's setInterval, but 
it's not really the good solution.

You can change it to (where ... are respectively the "before-selector 
selector" and "child-selector" in my sample).
Then, you can add a new css rule replace :with.... with ".-with-child-n".

        var cwc_count = 0;
        function createCSSWithChildRule(beforeSelector, childSelector, 
afterSelector, rule) {
            var count = cws_count; cws_count=cws_count+1;

            var sheet = document.createStyleSheet();
            sheet.cssText = beforeSelector + ".-with-child-"+count + " " + 
afterSelector + "{" + rule + "}";

            function update() {
                var divs = document.querySelectorAll(beforeSelector);
                var l=divs.length;
                for (var i=0; i<l; i++) {
                    if (divs[i].querySelector(childSelector)) {
                        divs[i].className="-with-child-"+count;
                    } else {
                        divs[i].className="";
                    }
                }
            }

            /* I don't have better solution if we must generalize in JScript 
*/
            setInterval(update, 500);
        }

    createCSSWithChildRule("body > div", "a:href", "a", "background: 
yellow")


Fremy 
Received on Wednesday, 23 July 2008 22:09:20 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:55:10 GMT