Changeset 43

Show
Ignore:
Timestamp:
07/14/05 03:14:27 (3 years ago)
Author:
bob
Message:

add sortable tables example
change isArrayLike to match latest Safari NodeList?
add scrapeText DOM function (and test)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mochikit/trunk/MochiKit/Base.js

    r38 r43  
    521521        if ( 
    522522            isUndefinedOrNull(o) || 
    523             typeof(o) != "object" || 
     523            typeof(o) == 'string' || 
    524524            typeof(o.length) != 'number' 
    525525        ) { 
  • mochikit/trunk/MochiKit/DOM.js

    r38 r43  
    579579showElement = partial(setDisplayForElements, "block"); 
    580580 
     581scrapeText = function (node) { 
     582    /*** 
     583     
     584        Walk a DOM tree and scrape all of the text out of it as an Array. 
     585 
     586    ***/ 
     587    var rval = []; 
     588    nodeWalk(node, function (node) { 
     589        var nodeValue = node.nodeValue; 
     590        if (typeof(nodeValue) == 'string') { 
     591            rval.push(nodeValue); 
     592        } 
     593        return node.childNodes; 
     594    }); 
     595    return rval; 
     596}; 
  • mochikit/trunk/tests/test_MochiKit-DOM.html

    r38 r43  
    1414         
    1515    // Counting the number of tests is really lame 
    16     plan({'tests': 14}); 
     16    plan({'tests': 16}); 
    1717 
    1818    lst = []; 
    1919    o = {"blah": function () { lst.push("original"); }}; 
    2020    addToCallStack(o, "blah", function () { lst.push("new"); }, true); 
    21     addToCallStack(o, "blah", function () { lst.push("shit"); }, true); 
     21    addToCallStack(o, "blah", function () { lst.push("stuff"); }, true); 
    2222    is( typeof(o.blah), 'function', 'addToCallStack has a function' ); 
    2323    is( o.blah.callStack.length, 3, 'callStack length 3' ); 
    2424    o.blah(); 
    25     is( lst.join(" "), "original new shit", "callStack in correct order" ); 
     25    is( lst.join(" "), "original new stuff", "callStack in correct order" ); 
    2626    is( o.blah, null, "set to null" ); 
    2727     
     
    5353 
    5454    isDOM( d, "<span>Goddamn, I like pork tacos</span>", "createDOM with custom converter" ); 
    55  
    56     // this we can test even on IE 
     55     
    5756    is( 
    5857        escapeHTML(toHTML(SPAN(null))), 
     
    6059        "createDOMFunc vs createDOM" 
    6160    ); 
     61 
     62    is( scrapeText(d).join(""), "Goddamn, I like pork tacos", "scrape OK" ); 
    6263 
    6364    ok( !isUndefinedOrNull(getElement("test")), "getElement might work" ); 
     
    6869    isDOM( d, "<span>unotwo</span>", "swapDOM" ); 
    6970 
     71    is( scrapeText(d).join(" "), "uno two", "multi-node scrapeText" ); 
    7072    /* 
    7173