Changeset 10989

Show
Ignore:
Timestamp:
05/03/08 02:28:10 (5 years ago)
Author:
gyuque
Message:

list separated attribute match

Location:
lang/actionscript/ascss/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/actionscript/ascss/src/SelectTest.as

    r10984 r10989  
    1515 
    1616                public static const TestCSS:String =  
    17 '.index em[title|="important"] {\n'+ 
     17'.index em[title~="foobar"] {\n'+ 
    1818' color: #940;\n'+ 
    1919'}\n\n'+ 
     
    2121' background-color: #ffe;\n'+ 
    2222'}\n\n'+ 
    23 '.index em[title|="foobar"] {\n'+ 
     23'.index em[title~="fooba"] {\n'+ 
    2424' background-color: #f7e;\n'+ 
    2525'}\n\n'+ 
     
    3030                public static const TestDoc:XML =  
    3131<body class="new index"> 
    32         <em class="em1" title="important-1">foobar</em> 
     32        <em class="em1" title="important-1 foobar">foobar</em> 
    3333</body> 
    3434; 
  • lang/actionscript/ascss/src/css/CSSStyleSelector.as

    r10985 r10989  
    431431                                                return false; 
    432432                                        break; 
     433                                case CSSSelector.List: 
     434                                { 
     435                                        // Ignore empty selectors or selectors containing spaces 
     436                                        if (str_contains(sel.m_value, ' ', false) || sel.m_value == "") 
     437                                                return false; 
     438                 
     439                                        var startSearchAt:int = 0; 
     440                                        var s_val:String = value; 
     441                                        var s_sel:String = sel.m_value; 
     442 
     443                                        if (caseSensitive) 
     444                                        { 
     445                                                s_val = s_val.toLowerCase(); 
     446                                                s_sel = s_sel.toLowerCase(); 
     447                                        } 
     448 
     449                                        while (true) { 
     450                                                var foundPos:int = s_val.indexOf(s_sel, startSearchAt); 
     451                                                if (foundPos == -1) 
     452                                                        return false; 
     453                                                if (foundPos == 0 || value.charAt(foundPos-1) == ' ') { 
     454                                                        var endStr:uint = foundPos + sel.m_value.length; 
     455                                                        if (endStr == value.length || value.charAt(endStr) == ' ') 
     456                                                                break; // We found a match. 
     457                                                } 
     458                                                 
     459                                                // No match.  Keep looking. 
     460                                                startSearchAt = foundPos + 1; 
     461                                        } 
     462                                        break; 
     463                                } 
    433464                                case CSSSelector.Contain: 
    434465                                        if (!str_contains(value, sel.m_value, caseSensitive))