envjs 0.3.7 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,16 @@
1
+ === 0.3.8 / 2010-09-14
2
+
3
+ * don't use static variable in cookie processing
4
+ * return name() lower case in html
5
+ * update url even when only hash change
6
+ * don't error out trying to remove event that doesn't exist (orslumen)
7
+ * When serializing multipart/form-data forms we need a pair of \r\n between the boundary and headers and the data value. Not just one. [Murray Steele]
8
+ * Fix for http://github.com/smparkes/env-js/issues/issue/19 [fiann]
9
+ * rejigger things so the xml parser works on XHR requests; pretty much just moving code
10
+ * add some dimensions that query ui needs to (barely) function
11
+ * include document ref in defaultView
12
+ * add some properties that help d&d simulation
13
+
1
14
  === 0.3.7 / 2010-07-05
2
15
 
3
16
  * Add support for https (heathkit)
@@ -272,6 +272,7 @@ test/unit/dom.js
272
272
  test/unit/elementmembers.js
273
273
  test/unit/events.js
274
274
  test/unit/fixtures/external_script.js
275
+ test/unit/form.js
275
276
  test/unit/iframe.js
276
277
  test/unit/insertion.js
277
278
  test/unit/multi-window.js
@@ -1,6 +1,6 @@
1
1
  module Envjs
2
2
 
3
- VERSION = "0.3.7"
3
+ VERSION = "0.3.8"
4
4
 
5
5
  def self.js_exception_stack e
6
6
  result = %(Exception: )+e.to_s
@@ -145,7 +145,7 @@ try {
145
145
  this.window = this;
146
146
  }
147
147
  $env.log = function(msg, level){
148
- debug(' '+ (level?level:'LOG') + ':\t['+ new Date()+"] {ENVJS} "+msg);
148
+ print(' '+ (level?level:'LOG') + ':\t['+ new Date()+"] {ENVJS} "+msg);
149
149
  };
150
150
 
151
151
  $env.location = function(path, base){
@@ -1274,7 +1274,7 @@ __extend__(DOMImplementation.prototype,{
1274
1274
  createDocument : function(nsuri, qname, doctype){
1275
1275
  //TODO - this currently returns an empty doc
1276
1276
  //but needs to handle the args
1277
- return new Document(this, null);
1277
+ return new DOMDocument(this, null);
1278
1278
  },
1279
1279
  createHTMLDocument : function(title){
1280
1280
  // N.B. explict window on purpose ...
@@ -1363,468 +1363,6 @@ __extend__(DOMImplementation.prototype,{
1363
1363
  });
1364
1364
 
1365
1365
 
1366
- /**
1367
- * Defined 'globally' to this scope. Remember everything is wrapped in a closure so this doesnt show up
1368
- * in the outer most global scope.
1369
- */
1370
-
1371
- /**
1372
- * process SAX events
1373
- *
1374
- * @author Jon van Noort (jon@webarcana.com.au), David Joham (djoham@yahoo.com) and Scott Severtson
1375
- *
1376
- * @param impl : DOMImplementation
1377
- * @param doc : DOMDocument - the Document to contain the parsed XML string
1378
- * @param p : XMLP - the SAX Parser
1379
- *
1380
- * @return : DOMDocument
1381
- */
1382
-
1383
- function __parseLoop__(impl, doc, p, isWindowDocument) {
1384
- var iEvt, iNode, iAttr, strName;
1385
- var iNodeParent = doc;
1386
-
1387
- var el_close_count = 0;
1388
-
1389
- var entitiesList = new Array();
1390
- var textNodesList = new Array();
1391
-
1392
- // if namespaceAware, add default namespace
1393
- if (impl.namespaceAware) {
1394
- var iNS = doc.createNamespace(""); // add the default-default namespace
1395
- iNS.value = "http://www.w3.org/2000/xmlns/";
1396
- doc._namespaces.setNamedItem(iNS);
1397
- }
1398
-
1399
- // loop until SAX parser stops emitting events
1400
- var q = 0;
1401
- while(true) {
1402
- // get next event
1403
- iEvt = p.next();
1404
-
1405
- if (iEvt == XMLP._ELM_B) { // Begin-Element Event
1406
- var pName = p.getName(); // get the Element name
1407
- pName = trim(pName, true, true); // strip spaces from Element name
1408
- if(pName.toLowerCase() == 'script')
1409
- p.replaceEntities = false;
1410
-
1411
- if (!impl.namespaceAware) {
1412
- iNode = doc.createElement(p.getName()); // create the Element
1413
- // add attributes to Element
1414
- for(var i = 0; i < p.getAttributeCount(); i++) {
1415
- strName = p.getAttributeName(i); // get Attribute name
1416
- iAttr = iNode.getAttributeNode(strName); // if Attribute exists, use it
1417
-
1418
- if(!iAttr) {
1419
- iAttr = doc.createAttribute(strName); // otherwise create it
1420
- }
1421
-
1422
- iAttr.value = p.getAttributeValue(i); // set Attribute value
1423
- iNode.setAttributeNode(iAttr); // attach Attribute to Element
1424
- }
1425
- }
1426
- else { // Namespace Aware
1427
- // create element (with empty namespaceURI,
1428
- // resolve after namespace 'attributes' have been parsed)
1429
- iNode = doc.createElementNS("", p.getName());
1430
-
1431
- // duplicate ParentNode's Namespace definitions
1432
- iNode._namespaces = __cloneNamedNodes__(iNodeParent._namespaces, iNode, true);
1433
-
1434
- // add attributes to Element
1435
- for(var i = 0; i < p.getAttributeCount(); i++) {
1436
- strName = p.getAttributeName(i); // get Attribute name
1437
-
1438
- // if attribute is a namespace declaration
1439
- if (__isNamespaceDeclaration__(strName)) {
1440
- // parse Namespace Declaration
1441
- var namespaceDec = __parseNSName__(strName);
1442
-
1443
- if (strName != "xmlns") {
1444
- iNS = doc.createNamespace(strName); // define namespace
1445
- }
1446
- else {
1447
- iNS = doc.createNamespace(""); // redefine default namespace
1448
- }
1449
- iNS.value = p.getAttributeValue(i); // set value = namespaceURI
1450
-
1451
- iNode._namespaces.setNamedItem(iNS); // attach namespace to namespace collection
1452
- }
1453
- else { // otherwise, it is a normal attribute
1454
- iAttr = iNode.getAttributeNode(strName); // if Attribute exists, use it
1455
-
1456
- if(!iAttr) {
1457
- iAttr = doc.createAttributeNS("", strName); // otherwise create it
1458
- }
1459
-
1460
- iAttr.value = p.getAttributeValue(i); // set Attribute value
1461
- iNode.setAttributeNodeNS(iAttr); // attach Attribute to Element
1462
-
1463
- if (__isIdDeclaration__(strName)) {
1464
- iNode.id = p.getAttributeValue(i); // cache ID for getElementById()
1465
- }
1466
- }
1467
- }
1468
-
1469
- // resolve namespaceURIs for this Element
1470
- if (iNode._namespaces.getNamedItem(iNode.prefix)) {
1471
- iNode.namespaceURI = iNode._namespaces.getNamedItem(iNode.prefix).value;
1472
- } else {
1473
- iNode.namespaceURI = iNodeParent.namespaceURI;
1474
- }
1475
-
1476
- // for this Element's attributes
1477
- for (var i = 0; i < iNode.attributes.length; i++) {
1478
- if (iNode.attributes.item(i).prefix != "") { // attributes do not have a default namespace
1479
- if (iNode._namespaces.getNamedItem(iNode.attributes.item(i).prefix)) {
1480
- iNode.attributes.item(i).namespaceURI = iNode._namespaces.getNamedItem(iNode.attributes.item(i).prefix).value;
1481
- }
1482
- }
1483
- }
1484
-
1485
- // We didn't know the NS of the node when we created it, which means we created a default DOM object.
1486
- // Now that we know the NS, if there is one, we clone this node so that it'll get created under
1487
- // with the right constructor. This makes things like SVG work. Might be nice not to create twice as
1488
- // as many nodes, but that's painfully given the complexity of namespaces.
1489
- if(iNode.namespaceURI != ""){
1490
- iNode = iNode.cloneNode();
1491
- }
1492
- }
1493
-
1494
- // if this is the Root Element
1495
- if (iNodeParent.nodeType == DOMNode.DOCUMENT_NODE) {
1496
- iNodeParent._documentElement = iNode; // register this Element as the Document.documentElement
1497
- }
1498
-
1499
- iNodeParent.appendChild(iNode); // attach Element to parentNode
1500
- iNodeParent = iNode; // descend one level of the DOM Tree
1501
- }
1502
-
1503
- else if(iEvt == XMLP._ELM_E) { // End-Element Event
1504
- iNodeParent = iNodeParent.parentNode; // ascend one level of the DOM Tree
1505
- }
1506
-
1507
- else if(iEvt == XMLP._ELM_EMP) { // Empty Element Event
1508
- pName = p.getName(); // get the Element name
1509
- pName = trim(pName, true, true); // strip spaces from Element name
1510
-
1511
- if (!impl.namespaceAware) {
1512
- iNode = doc.createElement(pName); // create the Element
1513
-
1514
- // add attributes to Element
1515
- for(var i = 0; i < p.getAttributeCount(); i++) {
1516
- strName = p.getAttributeName(i); // get Attribute name
1517
- iAttr = iNode.getAttributeNode(strName); // if Attribute exists, use it
1518
-
1519
- if(!iAttr) {
1520
- iAttr = doc.createAttribute(strName); // otherwise create it
1521
- }
1522
-
1523
- iAttr.value = p.getAttributeValue(i); // set Attribute value
1524
- iNode.setAttributeNode(iAttr); // attach Attribute to Element
1525
- }
1526
- }
1527
- else { // Namespace Aware
1528
- // create element (with empty namespaceURI,
1529
- // resolve after namespace 'attributes' have been parsed)
1530
- iNode = doc.createElementNS("", p.getName());
1531
-
1532
- // duplicate ParentNode's Namespace definitions
1533
- iNode._namespaces = __cloneNamedNodes__(iNodeParent._namespaces, iNode);
1534
-
1535
- // add attributes to Element
1536
- for(var i = 0; i < p.getAttributeCount(); i++) {
1537
- strName = p.getAttributeName(i); // get Attribute name
1538
-
1539
- // if attribute is a namespace declaration
1540
- if (__isNamespaceDeclaration__(strName)) {
1541
- // parse Namespace Declaration
1542
- var namespaceDec = __parseNSName__(strName);
1543
-
1544
- if (strName != "xmlns") {
1545
- iNS = doc.createNamespace(strName); // define namespace
1546
- }
1547
- else {
1548
- iNS = doc.createNamespace(""); // redefine default namespace
1549
- }
1550
- iNS.value = p.getAttributeValue(i); // set value = namespaceURI
1551
-
1552
- iNode._namespaces.setNamedItem(iNS); // attach namespace to namespace collection
1553
- }
1554
- else { // otherwise, it is a normal attribute
1555
- iAttr = iNode.getAttributeNode(strName); // if Attribute exists, use it
1556
-
1557
- if(!iAttr) {
1558
- iAttr = doc.createAttributeNS("", strName); // otherwise create it
1559
- }
1560
-
1561
- iAttr.value = p.getAttributeValue(i); // set Attribute value
1562
- iNode.setAttributeNodeNS(iAttr); // attach Attribute to Element
1563
-
1564
- if (__isIdDeclaration__(strName)) {
1565
- iNode.id = p.getAttributeValue(i); // cache ID for getElementById()
1566
- }
1567
- }
1568
- }
1569
-
1570
- // resolve namespaceURIs for this Element
1571
- if (iNode._namespaces.getNamedItem(iNode.prefix)) {
1572
- iNode.namespaceURI = iNode._namespaces.getNamedItem(iNode.prefix).value;
1573
- }
1574
-
1575
- // for this Element's attributes
1576
- for (var i = 0; i < iNode.attributes.length; i++) {
1577
- if (iNode.attributes.item(i).prefix != "") { // attributes do not have a default namespace
1578
- if (iNode._namespaces.getNamedItem(iNode.attributes.item(i).prefix)) {
1579
- iNode.attributes.item(i).namespaceURI = iNode._namespaces.getNamedItem(iNode.attributes.item(i).prefix).value;
1580
- }
1581
- }
1582
- }
1583
- }
1584
-
1585
- // if this is the Root Element
1586
- if (iNodeParent.nodeType == DOMNode.DOCUMENT_NODE) {
1587
- iNodeParent._documentElement = iNode; // register this Element as the Document.documentElement
1588
- }
1589
-
1590
- iNodeParent.appendChild(iNode); // attach Element to parentNode
1591
- }
1592
- else if(iEvt == XMLP._TEXT || iEvt == XMLP._ENTITY) { // TextNode and entity Events
1593
- // get Text content
1594
- var pContent = p.getContent().substring(p.getContentBegin(), p.getContentEnd());
1595
-
1596
- if (!impl.preserveWhiteSpace ) {
1597
- if (trim(pContent, true, true) == "") {
1598
- pContent = ""; //this will cause us not to create the text node below
1599
- }
1600
- }
1601
-
1602
- if (pContent.length > 0) { // ignore empty TextNodes
1603
- var textNode = doc.createTextNode(pContent);
1604
- iNodeParent.appendChild(textNode); // attach TextNode to parentNode
1605
-
1606
- //the sax parser breaks up text nodes when it finds an entity. For
1607
- //example hello&lt;there will fire a text, an entity and another text
1608
- //this sucks for the dom parser because it looks to us in this logic
1609
- //as three text nodes. I fix this by keeping track of the entity nodes
1610
- //and when we're done parsing, calling normalize on their parent to
1611
- //turn the multiple text nodes into one, which is what DOM users expect
1612
- //the code to do this is at the bottom of this function
1613
- if (iEvt == XMLP._ENTITY) {
1614
- entitiesList[entitiesList.length] = textNode;
1615
- }
1616
- else {
1617
- //I can't properly decide how to handle preserve whitespace
1618
- //until the siblings of the text node are built due to
1619
- //the entitiy handling described above. I don't know that this
1620
- //will be all of the text node or not, so trimming is not appropriate
1621
- //at this time. Keep a list of all the text nodes for now
1622
- //and we'll process the preserve whitespace stuff at a later time.
1623
- textNodesList[textNodesList.length] = textNode;
1624
- }
1625
- }
1626
- }
1627
- else if(iEvt == XMLP._PI) { // ProcessingInstruction Event
1628
- // attach ProcessingInstruction to parentNode
1629
- iNodeParent.appendChild(doc.createProcessingInstruction(p.getName(), p.getContent().substring(p.getContentBegin(), p.getContentEnd())));
1630
- }
1631
- else if(iEvt == XMLP._CDATA) { // CDATA Event
1632
- // get CDATA data
1633
- pContent = p.getContent().substring(p.getContentBegin(), p.getContentEnd());
1634
-
1635
- if (!impl.preserveWhiteSpace) {
1636
- pContent = trim(pContent, true, true); // trim whitespace
1637
- pContent.replace(/ +/g, ' '); // collapse multiple spaces to 1 space
1638
- }
1639
-
1640
- if (pContent.length > 0) { // ignore empty CDATANodes
1641
- iNodeParent.appendChild(doc.createCDATASection(pContent)); // attach CDATA to parentNode
1642
- }
1643
- }
1644
- else if(iEvt == XMLP._COMMENT) { // Comment Event
1645
- // get COMMENT data
1646
- var pContent = p.getContent().substring(p.getContentBegin(), p.getContentEnd());
1647
-
1648
- if (!impl.preserveWhiteSpace) {
1649
- pContent = trim(pContent, true, true); // trim whitespace
1650
- pContent.replace(/ +/g, ' '); // collapse multiple spaces to 1 space
1651
- }
1652
-
1653
- if (pContent.length > 0) { // ignore empty CommentNodes
1654
- iNodeParent.appendChild(doc.createComment(pContent)); // attach Comment to parentNode
1655
- }
1656
- }
1657
- else if(iEvt == XMLP._DTD) { // ignore DTD events
1658
- }
1659
- else if(iEvt == XMLP._ERROR) {
1660
- $error("Fatal Error: " + p.getContent() +
1661
- "\nLine: " + p.getLineNumber() +
1662
- "\nColumn: " + p.getColumnNumber() + "\n");
1663
- throw(new DOMException(DOMException.SYNTAX_ERR));
1664
- }
1665
- else if(iEvt == XMLP._NONE) { // no more events
1666
- //steven woods notes that unclosed tags are rejected elsewhere and this check
1667
- //breaks a table patching routine
1668
- //if (iNodeParent == doc) { // confirm that we have recursed back up to root
1669
- // break;
1670
- //}
1671
- //else {
1672
- // throw(new DOMException(DOMException.SYNTAX_ERR)); // one or more Tags were not closed properly
1673
- //}
1674
- break;
1675
-
1676
- }
1677
- }
1678
-
1679
- //normalize any entities in the DOM to a single textNode
1680
- for (var i = 0; i < entitiesList.length; i++) {
1681
- var entity = entitiesList[i];
1682
- //its possible (if for example two entities were in the
1683
- //same domnode, that the normalize on the first entitiy
1684
- //will remove the parent for the second. Only do normalize
1685
- //if I can find a parent node
1686
- var parentNode = entity.parentNode;
1687
- if (parentNode) {
1688
- parentNode.normalize();
1689
-
1690
- //now do whitespace (if necessary)
1691
- //it was not done for text nodes that have entities
1692
- if(!impl.preserveWhiteSpace) {
1693
- var children = parentNode.childNodes;
1694
- for ( var j = 0; j < children.length; j++) {
1695
- var child = children.item(j);
1696
- if (child.nodeType == DOMNode.TEXT_NODE) {
1697
- var childData = child.data;
1698
- childData.replace(/\s/g, ' ');
1699
- child.data = childData;
1700
- }
1701
- }
1702
- }
1703
- }
1704
- }
1705
-
1706
- //do the preserve whitespace processing on the rest of the text nodes
1707
- //It's possible (due to the processing above) that the node will have been
1708
- //removed from the tree. Only do whitespace checking if parentNode is not null.
1709
- //This may duplicate the whitespace processing for some nodes that had entities in them
1710
- //but there's no way around that
1711
- if (!impl.preserveWhiteSpace) {
1712
- for (var i = 0; i < textNodesList.length; i++) {
1713
- var node = textNodesList[i];
1714
- if (node.parentNode != null) {
1715
- var nodeData = node.data;
1716
- nodeData.replace(/\s/g, ' ');
1717
- node.data = nodeData;
1718
- }
1719
- }
1720
-
1721
- }
1722
- };
1723
-
1724
-
1725
- /**
1726
- * @method DOMImplementation._isNamespaceDeclaration - Return true, if attributeName is a namespace declaration
1727
- * @author Jon van Noort (jon@webarcana.com.au)
1728
- * @param attributeName : string - the attribute name
1729
- * @return : boolean
1730
- */
1731
- function __isNamespaceDeclaration__(attributeName) {
1732
- // test if attributeName is 'xmlns'
1733
- return (attributeName.indexOf('xmlns') > -1);
1734
- };
1735
-
1736
- /**
1737
- * @method DOMImplementation._isIdDeclaration - Return true, if attributeName is an id declaration
1738
- * @author Jon van Noort (jon@webarcana.com.au)
1739
- * @param attributeName : string - the attribute name
1740
- * @return : boolean
1741
- */
1742
- function __isIdDeclaration__(attributeName) {
1743
- // test if attributeName is 'id' (case insensitive)
1744
- return attributeName?(attributeName.toLowerCase() == 'id'):false;
1745
- };
1746
-
1747
- /**
1748
- * @method DOMImplementation._isValidName - Return true,
1749
- * if name contains no invalid characters
1750
- * @author Jon van Noort (jon@webarcana.com.au)
1751
- * @param name : string - the candidate name
1752
- * @return : boolean
1753
- */
1754
- function __isValidName__(name) {
1755
- // test if name contains only valid characters
1756
- return name.match(re_validName);
1757
- };
1758
- var re_validName = /^[a-zA-Z_:][a-zA-Z0-9\.\-_:]*$/;
1759
-
1760
- /**
1761
- * @method DOMImplementation._isValidString - Return true, if string does not contain any illegal chars
1762
- * All of the characters 0 through 31 and character 127 are nonprinting control characters.
1763
- * With the exception of characters 09, 10, and 13, (Ox09, Ox0A, and Ox0D)
1764
- * Note: different from _isValidName in that ValidStrings may contain spaces
1765
- * @author Jon van Noort (jon@webarcana.com.au)
1766
- * @param name : string - the candidate string
1767
- * @return : boolean
1768
- */
1769
- function __isValidString__(name) {
1770
- // test that string does not contains invalid characters
1771
- return (name.search(re_invalidStringChars) < 0);
1772
- };
1773
- var re_invalidStringChars = /\x01|\x02|\x03|\x04|\x05|\x06|\x07|\x08|\x0B|\x0C|\x0E|\x0F|\x10|\x11|\x12|\x13|\x14|\x15|\x16|\x17|\x18|\x19|\x1A|\x1B|\x1C|\x1D|\x1E|\x1F|\x7F/;
1774
-
1775
- /**
1776
- * @method DOMImplementation._parseNSName - parse the namespace name.
1777
- * if there is no colon, the
1778
- * @author Jon van Noort (jon@webarcana.com.au)
1779
- * @param qualifiedName : string - The qualified name
1780
- * @return : NSName - [
1781
- .prefix : string - The prefix part of the qname
1782
- .namespaceName : string - The namespaceURI part of the qname
1783
- ]
1784
- */
1785
- function __parseNSName__(qualifiedName) {
1786
- var resultNSName = new Object();
1787
-
1788
- resultNSName.prefix = qualifiedName; // unless the qname has a namespaceName, the prefix is the entire String
1789
- resultNSName.namespaceName = "";
1790
-
1791
- // split on ':'
1792
- var delimPos = qualifiedName.indexOf(':');
1793
- if (delimPos > -1) {
1794
- // get prefix
1795
- resultNSName.prefix = qualifiedName.substring(0, delimPos);
1796
- // get namespaceName
1797
- resultNSName.namespaceName = qualifiedName.substring(delimPos +1, qualifiedName.length);
1798
- }
1799
- return resultNSName;
1800
- };
1801
-
1802
- /**
1803
- * @method DOMImplementation._parseQName - parse the qualified name
1804
- * @author Jon van Noort (jon@webarcana.com.au)
1805
- * @param qualifiedName : string - The qualified name
1806
- * @return : QName
1807
- */
1808
- function __parseQName__(qualifiedName) {
1809
- var resultQName = new Object();
1810
-
1811
- resultQName.localName = qualifiedName; // unless the qname has a prefix, the local name is the entire String
1812
- resultQName.prefix = "";
1813
-
1814
- // split on ':'
1815
- var delimPos = qualifiedName.indexOf(':');
1816
-
1817
- if (delimPos > -1) {
1818
- // get prefix
1819
- resultQName.prefix = qualifiedName.substring(0, delimPos);
1820
-
1821
- // get localName
1822
- resultQName.localName = qualifiedName.substring(delimPos +1, qualifiedName.length);
1823
- }
1824
-
1825
- return resultQName;
1826
- };
1827
-
1828
1366
  if(false){
1829
1367
  $debug("Initializing document.implementation");
1830
1368
  var $implementation = new DOMImplementation();
@@ -1849,11 +1387,12 @@ $env.__url = function(url){
1849
1387
  };
1850
1388
 
1851
1389
  $w.__defineSetter__("location", function(url){
1852
- if (false) {
1853
- if (url[0] === "#") {
1854
- // print("return anchor only");
1390
+ if (url[0] === "#") {
1391
+ window.location.hash = url;
1392
+ // print("return anchor only: "+window.location.href);
1855
1393
  return;
1856
- }
1394
+ }
1395
+ if (false) {
1857
1396
  var now = window.location.href.replace(/^file:\/\//,"").replace(/#.*/,"");
1858
1397
  var to = $master.first_script_window && $master.first_script_window.location.href;
1859
1398
  // var to = $env.location(url,window.location.href != "about:blank" ? window.location.href: undefined);
@@ -2155,6 +1694,9 @@ function __removeEventListener__(target, type, fn){
2155
1694
  target.uuid = $events.length;
2156
1695
  $events[target.uuid] = {};
2157
1696
  }
1697
+ if (!$events[target.uiid]) {
1698
+ return;
1699
+ }
2158
1700
  if ( !$events[target.uuid][type] ){
2159
1701
  $events[target.uuid][type] = [];
2160
1702
  }
@@ -2219,7 +1761,8 @@ function __dispatchEvent__(target, event, bubbles){
2219
1761
  var skip = false;
2220
1762
 
2221
1763
  if (url[0] === "#") {
2222
- // print("return anchor only");
1764
+ window.location.hash = url;
1765
+ // print("return anchor only: "+window.location);
2223
1766
  skip = true;
2224
1767
  }
2225
1768
 
@@ -2423,12 +1966,20 @@ XMLHttpRequest.prototype = {
2423
1966
  }else{
2424
1967
  try {
2425
1968
  $debug("parsing response text into xml document");
2426
- responseXML = $domparser.parseFromString(_this.responseText+"");
1969
+ /* responseXML = $domparser.parseFromString(_this.responseText+""); */
1970
+ responseXML =
1971
+ document.implementation.createDocument().
1972
+ loadXML(_this.responseText+"");
2427
1973
  return responseXML;
2428
1974
  } catch(e) {
2429
1975
  $error('response XML does not apear to be well formed xml', e);
1976
+ /*
2430
1977
  responseXML = $domparser.parseFromString("<html>"+
2431
1978
  "<head/><body><p> parse error </p></body></html>");
1979
+ */
1980
+ responseXML =
1981
+ document.implementation.createDocument().
1982
+ loadXML("<html><head/><body><p> parse error </p></body></html>");
2432
1983
  return responseXML;
2433
1984
  }
2434
1985
  }