Changeset 1338

Show
Ignore:
Timestamp:
11/12/07 22:22:58 (6 years ago)
Author:
amachang
Message:

lang/javascript/javascript-xpath/trunk: Release 0.1.3

Location:
lang/javascript/javascript-xpath/trunk
Files:
1 added
5 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/javascript-xpath/trunk/ChangeLog

    r1332 r1338  
     1== 0.1.3 / 2007-11-12  amachang <seijro@gmail.com> 
     2 
     3        * fix Opera's substring problem 
     4        * fix Safari2's element.contains problem 
     5 
    16== 0.1.2 / 2007-11-12  amachang <seijro@gmail.com> 
    27 
  • lang/javascript/javascript-xpath/trunk/release/javascript-xpath-latest.js

    r1332 r1338  
    1 /*  JavaScript-XPath 0.1.2 
     1/*  JavaScript-XPath 0.1.3 
    22 *  (c) 2007 Cybozu Labs, Inc. 
    33 * 
     
    684684        if (!step.needContextPosition && step.axis == 'following') { 
    685685            for (node = iter(); next = iter(); node = next) { 
    686                 try { if (!node.contains(next)) break } 
    687                 catch(e) { if (!(next.compareDocumentPosition(node) & 8)) break } 
     686 
     687                // Safari 2 node.contains problem 
     688                if (uai.applewebkit4) { 
     689                    var contains = false; 
     690                    var ancestor = next; 
     691                    do { 
     692                        if (ancestor == node) { 
     693                            contains = true; 
     694                            break; 
     695                        } 
     696                    } while (ancestor = ancestor.parentNode); 
     697                    if (!contains) break; 
     698                } 
     699                else { 
     700                    try { if (!node.contains(next)) break } 
     701                    catch(e) { if (!(next.compareDocumentPosition(node) & 8)) break } 
     702                } 
    688703            } 
    689704            nodeset = step.evaluate(new Ctx(node)); 
     
    18541869 
    18551870    substring: [function(s, n1, n2) { 
     1871        var a1, a2; 
    18561872        s = s.string(this); 
    18571873        n1 = n1.number(this); 
     
    18691885        n1 = Math.round(n1); 
    18701886        n2 = Math.round(n2); 
    1871         return s.substring(n1 - 1, n1 + n2 - 1) 
     1887        a1 = n1 - 1; 
     1888        a2 = n1 + n2 - 1; 
     1889        if (a2 == Infinity) { 
     1890            return s.substring(a1 < 0 ? 0 : a1); 
     1891        } 
     1892        else { 
     1893            return s.substring(a1 < 0 ? 0 : a1, a2) 
     1894        } 
    18721895    }, 'string', false, []], 
    18731896 
  • lang/javascript/javascript-xpath/trunk/src/functionCall.js

    r1325 r1338  
    196196 
    197197    substring: [function(s, n1, n2) { 
     198        var a1, a2; 
    198199        s = s.string(this); 
    199200        n1 = n1.number(this); 
     
    211212        n1 = Math.round(n1); 
    212213        n2 = Math.round(n2); 
    213         return s.substring(n1 - 1, n1 + n2 - 1) 
     214        a1 = n1 - 1; 
     215        a2 = n1 + n2 - 1; 
     216        if (a2 == Infinity) { 
     217            return s.substring(a1 < 0 ? 0 : a1); 
     218        } 
     219        else { 
     220            return s.substring(a1 < 0 ? 0 : a1, a2) 
     221        } 
    214222    }, 'string', false, []], 
    215223 
  • lang/javascript/javascript-xpath/trunk/src/pathExpr.js

    r1269 r1338  
    7777        if (!step.needContextPosition && step.axis == 'following') { 
    7878            for (node = iter(); next = iter(); node = next) { 
    79                 try { if (!node.contains(next)) break } 
    80                 catch(e) { if (!(next.compareDocumentPosition(node) & 8)) break } 
     79 
     80                // Safari 2 node.contains problem 
     81                if (uai.applewebkit4) { 
     82                    var contains = false; 
     83                    var ancestor = next; 
     84                    do { 
     85                        if (ancestor == node) { 
     86                            contains = true; 
     87                            break; 
     88                        } 
     89                    } while (ancestor = ancestor.parentNode); 
     90                    if (!contains) break; 
     91                } 
     92                else { 
     93                    try { if (!node.contains(next)) break } 
     94                    catch(e) { if (!(next.compareDocumentPosition(node) & 8)) break } 
     95                } 
    8196            } 
    8297            nodeset = step.evaluate(new Ctx(node)); 
  • lang/javascript/javascript-xpath/trunk/version.txt

    r1332 r1338  
    1 0.1.2 
     10.1.3