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.
- data/CHANGELOG.rdoc +13 -0
- data/Manifest.txt +1 -0
- data/lib/envjs.rb +1 -1
- data/lib/envjs/env.js +21 -470
- data/lib/envjs/static.js +505 -9
- data/src/css/properties.js +3 -3
- data/src/dom/document.js +474 -4
- data/src/dom/implementation.js +1 -463
- data/src/html/cookie.js +3 -1
- data/src/html/element.js +2 -0
- data/src/html/form.js +1 -1
- data/src/platform/johnson.js +1 -1
- data/src/window/event.js +5 -1
- data/src/window/location.js +5 -4
- data/src/window/xhr.js +9 -1
- data/src/xpath/implementation.js +22 -0
- data/test/primary-tests.js +1 -0
- data/test/unit/form.js +40 -0
- metadata +5 -4
data/lib/envjs/static.js
CHANGED
@@ -3502,6 +3502,368 @@ var $entityDefinitions = {
|
|
3502
3502
|
|
3503
3503
|
|
3504
3504
|
$debug("Defining Document");
|
3505
|
+
|
3506
|
+
/**
|
3507
|
+
* Defined 'globally' to this scope. Remember everything is wrapped in a closure so this doesnt show up
|
3508
|
+
* in the outer most global scope.
|
3509
|
+
*/
|
3510
|
+
|
3511
|
+
/**
|
3512
|
+
* process SAX events
|
3513
|
+
*
|
3514
|
+
* @author Jon van Noort (jon@webarcana.com.au), David Joham (djoham@yahoo.com) and Scott Severtson
|
3515
|
+
*
|
3516
|
+
* @param impl : DOMImplementation
|
3517
|
+
* @param doc : DOMDocument - the Document to contain the parsed XML string
|
3518
|
+
* @param p : XMLP - the SAX Parser
|
3519
|
+
*
|
3520
|
+
* @return : DOMDocument
|
3521
|
+
*/
|
3522
|
+
|
3523
|
+
function __parseLoop__(impl, doc, p, isWindowDocument) {
|
3524
|
+
var iEvt, iNode, iAttr, strName;
|
3525
|
+
var iNodeParent = doc;
|
3526
|
+
|
3527
|
+
var el_close_count = 0;
|
3528
|
+
|
3529
|
+
var entitiesList = new Array();
|
3530
|
+
var textNodesList = new Array();
|
3531
|
+
|
3532
|
+
// if namespaceAware, add default namespace
|
3533
|
+
if (impl.namespaceAware) {
|
3534
|
+
var iNS = doc.createNamespace(""); // add the default-default namespace
|
3535
|
+
iNS.value = "http://www.w3.org/2000/xmlns/";
|
3536
|
+
doc._namespaces.setNamedItem(iNS);
|
3537
|
+
}
|
3538
|
+
|
3539
|
+
// loop until SAX parser stops emitting events
|
3540
|
+
var q = 0;
|
3541
|
+
while(true) {
|
3542
|
+
// get next event
|
3543
|
+
iEvt = p.next();
|
3544
|
+
|
3545
|
+
if (iEvt == XMLP._ELM_B) { // Begin-Element Event
|
3546
|
+
var pName = p.getName(); // get the Element name
|
3547
|
+
pName = trim(pName, true, true); // strip spaces from Element name
|
3548
|
+
if(pName.toLowerCase() == 'script')
|
3549
|
+
p.replaceEntities = false;
|
3550
|
+
|
3551
|
+
if (!impl.namespaceAware) {
|
3552
|
+
iNode = doc.createElement(p.getName()); // create the Element
|
3553
|
+
// add attributes to Element
|
3554
|
+
for(var i = 0; i < p.getAttributeCount(); i++) {
|
3555
|
+
strName = p.getAttributeName(i); // get Attribute name
|
3556
|
+
iAttr = iNode.getAttributeNode(strName); // if Attribute exists, use it
|
3557
|
+
|
3558
|
+
if(!iAttr) {
|
3559
|
+
iAttr = doc.createAttribute(strName); // otherwise create it
|
3560
|
+
}
|
3561
|
+
|
3562
|
+
iAttr.value = p.getAttributeValue(i); // set Attribute value
|
3563
|
+
iNode.setAttributeNode(iAttr); // attach Attribute to Element
|
3564
|
+
}
|
3565
|
+
}
|
3566
|
+
else { // Namespace Aware
|
3567
|
+
// create element (with empty namespaceURI,
|
3568
|
+
// resolve after namespace 'attributes' have been parsed)
|
3569
|
+
iNode = doc.createElementNS("", p.getName());
|
3570
|
+
|
3571
|
+
// duplicate ParentNode's Namespace definitions
|
3572
|
+
iNode._namespaces = __cloneNamedNodes__(iNodeParent._namespaces, iNode, true);
|
3573
|
+
|
3574
|
+
// add attributes to Element
|
3575
|
+
for(var i = 0; i < p.getAttributeCount(); i++) {
|
3576
|
+
strName = p.getAttributeName(i); // get Attribute name
|
3577
|
+
|
3578
|
+
// if attribute is a namespace declaration
|
3579
|
+
if (__isNamespaceDeclaration__(strName)) {
|
3580
|
+
// parse Namespace Declaration
|
3581
|
+
var namespaceDec = __parseNSName__(strName);
|
3582
|
+
|
3583
|
+
if (strName != "xmlns") {
|
3584
|
+
iNS = doc.createNamespace(strName); // define namespace
|
3585
|
+
}
|
3586
|
+
else {
|
3587
|
+
iNS = doc.createNamespace(""); // redefine default namespace
|
3588
|
+
}
|
3589
|
+
iNS.value = p.getAttributeValue(i); // set value = namespaceURI
|
3590
|
+
|
3591
|
+
iNode._namespaces.setNamedItem(iNS); // attach namespace to namespace collection
|
3592
|
+
}
|
3593
|
+
else { // otherwise, it is a normal attribute
|
3594
|
+
iAttr = iNode.getAttributeNode(strName); // if Attribute exists, use it
|
3595
|
+
|
3596
|
+
if(!iAttr) {
|
3597
|
+
iAttr = doc.createAttributeNS("", strName); // otherwise create it
|
3598
|
+
}
|
3599
|
+
|
3600
|
+
iAttr.value = p.getAttributeValue(i); // set Attribute value
|
3601
|
+
iNode.setAttributeNodeNS(iAttr); // attach Attribute to Element
|
3602
|
+
|
3603
|
+
if (__isIdDeclaration__(strName)) {
|
3604
|
+
iNode.id = p.getAttributeValue(i); // cache ID for getElementById()
|
3605
|
+
}
|
3606
|
+
}
|
3607
|
+
}
|
3608
|
+
|
3609
|
+
// resolve namespaceURIs for this Element
|
3610
|
+
if (iNode._namespaces.getNamedItem(iNode.prefix)) {
|
3611
|
+
iNode.namespaceURI = iNode._namespaces.getNamedItem(iNode.prefix).value;
|
3612
|
+
} else {
|
3613
|
+
iNode.namespaceURI = iNodeParent.namespaceURI;
|
3614
|
+
}
|
3615
|
+
|
3616
|
+
// for this Element's attributes
|
3617
|
+
for (var i = 0; i < iNode.attributes.length; i++) {
|
3618
|
+
if (iNode.attributes.item(i).prefix != "") { // attributes do not have a default namespace
|
3619
|
+
if (iNode._namespaces.getNamedItem(iNode.attributes.item(i).prefix)) {
|
3620
|
+
iNode.attributes.item(i).namespaceURI = iNode._namespaces.getNamedItem(iNode.attributes.item(i).prefix).value;
|
3621
|
+
}
|
3622
|
+
}
|
3623
|
+
}
|
3624
|
+
|
3625
|
+
// We didn't know the NS of the node when we created it, which means we created a default DOM object.
|
3626
|
+
// Now that we know the NS, if there is one, we clone this node so that it'll get created under
|
3627
|
+
// with the right constructor. This makes things like SVG work. Might be nice not to create twice as
|
3628
|
+
// as many nodes, but that's painfully given the complexity of namespaces.
|
3629
|
+
if(iNode.namespaceURI != ""){
|
3630
|
+
iNode = iNode.cloneNode();
|
3631
|
+
}
|
3632
|
+
}
|
3633
|
+
|
3634
|
+
// if this is the Root Element
|
3635
|
+
if (iNodeParent.nodeType == DOMNode.DOCUMENT_NODE) {
|
3636
|
+
iNodeParent._documentElement = iNode; // register this Element as the Document.documentElement
|
3637
|
+
}
|
3638
|
+
|
3639
|
+
iNodeParent.appendChild(iNode); // attach Element to parentNode
|
3640
|
+
iNodeParent = iNode; // descend one level of the DOM Tree
|
3641
|
+
}
|
3642
|
+
|
3643
|
+
else if(iEvt == XMLP._ELM_E) { // End-Element Event
|
3644
|
+
iNodeParent = iNodeParent.parentNode; // ascend one level of the DOM Tree
|
3645
|
+
}
|
3646
|
+
|
3647
|
+
else if(iEvt == XMLP._ELM_EMP) { // Empty Element Event
|
3648
|
+
pName = p.getName(); // get the Element name
|
3649
|
+
pName = trim(pName, true, true); // strip spaces from Element name
|
3650
|
+
|
3651
|
+
if (!impl.namespaceAware) {
|
3652
|
+
iNode = doc.createElement(pName); // create the Element
|
3653
|
+
|
3654
|
+
// add attributes to Element
|
3655
|
+
for(var i = 0; i < p.getAttributeCount(); i++) {
|
3656
|
+
strName = p.getAttributeName(i); // get Attribute name
|
3657
|
+
iAttr = iNode.getAttributeNode(strName); // if Attribute exists, use it
|
3658
|
+
|
3659
|
+
if(!iAttr) {
|
3660
|
+
iAttr = doc.createAttribute(strName); // otherwise create it
|
3661
|
+
}
|
3662
|
+
|
3663
|
+
iAttr.value = p.getAttributeValue(i); // set Attribute value
|
3664
|
+
iNode.setAttributeNode(iAttr); // attach Attribute to Element
|
3665
|
+
}
|
3666
|
+
}
|
3667
|
+
else { // Namespace Aware
|
3668
|
+
// create element (with empty namespaceURI,
|
3669
|
+
// resolve after namespace 'attributes' have been parsed)
|
3670
|
+
iNode = doc.createElementNS("", p.getName());
|
3671
|
+
|
3672
|
+
// duplicate ParentNode's Namespace definitions
|
3673
|
+
iNode._namespaces = __cloneNamedNodes__(iNodeParent._namespaces, iNode);
|
3674
|
+
|
3675
|
+
// add attributes to Element
|
3676
|
+
for(var i = 0; i < p.getAttributeCount(); i++) {
|
3677
|
+
strName = p.getAttributeName(i); // get Attribute name
|
3678
|
+
|
3679
|
+
// if attribute is a namespace declaration
|
3680
|
+
if (__isNamespaceDeclaration__(strName)) {
|
3681
|
+
// parse Namespace Declaration
|
3682
|
+
var namespaceDec = __parseNSName__(strName);
|
3683
|
+
|
3684
|
+
if (strName != "xmlns") {
|
3685
|
+
iNS = doc.createNamespace(strName); // define namespace
|
3686
|
+
}
|
3687
|
+
else {
|
3688
|
+
iNS = doc.createNamespace(""); // redefine default namespace
|
3689
|
+
}
|
3690
|
+
iNS.value = p.getAttributeValue(i); // set value = namespaceURI
|
3691
|
+
|
3692
|
+
iNode._namespaces.setNamedItem(iNS); // attach namespace to namespace collection
|
3693
|
+
}
|
3694
|
+
else { // otherwise, it is a normal attribute
|
3695
|
+
iAttr = iNode.getAttributeNode(strName); // if Attribute exists, use it
|
3696
|
+
|
3697
|
+
if(!iAttr) {
|
3698
|
+
iAttr = doc.createAttributeNS("", strName); // otherwise create it
|
3699
|
+
}
|
3700
|
+
|
3701
|
+
iAttr.value = p.getAttributeValue(i); // set Attribute value
|
3702
|
+
iNode.setAttributeNodeNS(iAttr); // attach Attribute to Element
|
3703
|
+
|
3704
|
+
if (__isIdDeclaration__(strName)) {
|
3705
|
+
iNode.id = p.getAttributeValue(i); // cache ID for getElementById()
|
3706
|
+
}
|
3707
|
+
}
|
3708
|
+
}
|
3709
|
+
|
3710
|
+
// resolve namespaceURIs for this Element
|
3711
|
+
if (iNode._namespaces.getNamedItem(iNode.prefix)) {
|
3712
|
+
iNode.namespaceURI = iNode._namespaces.getNamedItem(iNode.prefix).value;
|
3713
|
+
}
|
3714
|
+
|
3715
|
+
// for this Element's attributes
|
3716
|
+
for (var i = 0; i < iNode.attributes.length; i++) {
|
3717
|
+
if (iNode.attributes.item(i).prefix != "") { // attributes do not have a default namespace
|
3718
|
+
if (iNode._namespaces.getNamedItem(iNode.attributes.item(i).prefix)) {
|
3719
|
+
iNode.attributes.item(i).namespaceURI = iNode._namespaces.getNamedItem(iNode.attributes.item(i).prefix).value;
|
3720
|
+
}
|
3721
|
+
}
|
3722
|
+
}
|
3723
|
+
}
|
3724
|
+
|
3725
|
+
// if this is the Root Element
|
3726
|
+
if (iNodeParent.nodeType == DOMNode.DOCUMENT_NODE) {
|
3727
|
+
iNodeParent._documentElement = iNode; // register this Element as the Document.documentElement
|
3728
|
+
}
|
3729
|
+
|
3730
|
+
iNodeParent.appendChild(iNode); // attach Element to parentNode
|
3731
|
+
}
|
3732
|
+
else if(iEvt == XMLP._TEXT || iEvt == XMLP._ENTITY) { // TextNode and entity Events
|
3733
|
+
// get Text content
|
3734
|
+
var pContent = p.getContent().substring(p.getContentBegin(), p.getContentEnd());
|
3735
|
+
|
3736
|
+
if (!impl.preserveWhiteSpace ) {
|
3737
|
+
if (trim(pContent, true, true) == "") {
|
3738
|
+
pContent = ""; //this will cause us not to create the text node below
|
3739
|
+
}
|
3740
|
+
}
|
3741
|
+
|
3742
|
+
if (pContent.length > 0) { // ignore empty TextNodes
|
3743
|
+
var textNode = doc.createTextNode(pContent);
|
3744
|
+
iNodeParent.appendChild(textNode); // attach TextNode to parentNode
|
3745
|
+
|
3746
|
+
//the sax parser breaks up text nodes when it finds an entity. For
|
3747
|
+
//example hello<there will fire a text, an entity and another text
|
3748
|
+
//this sucks for the dom parser because it looks to us in this logic
|
3749
|
+
//as three text nodes. I fix this by keeping track of the entity nodes
|
3750
|
+
//and when we're done parsing, calling normalize on their parent to
|
3751
|
+
//turn the multiple text nodes into one, which is what DOM users expect
|
3752
|
+
//the code to do this is at the bottom of this function
|
3753
|
+
if (iEvt == XMLP._ENTITY) {
|
3754
|
+
entitiesList[entitiesList.length] = textNode;
|
3755
|
+
}
|
3756
|
+
else {
|
3757
|
+
//I can't properly decide how to handle preserve whitespace
|
3758
|
+
//until the siblings of the text node are built due to
|
3759
|
+
//the entitiy handling described above. I don't know that this
|
3760
|
+
//will be all of the text node or not, so trimming is not appropriate
|
3761
|
+
//at this time. Keep a list of all the text nodes for now
|
3762
|
+
//and we'll process the preserve whitespace stuff at a later time.
|
3763
|
+
textNodesList[textNodesList.length] = textNode;
|
3764
|
+
}
|
3765
|
+
}
|
3766
|
+
}
|
3767
|
+
else if(iEvt == XMLP._PI) { // ProcessingInstruction Event
|
3768
|
+
// attach ProcessingInstruction to parentNode
|
3769
|
+
iNodeParent.appendChild(doc.createProcessingInstruction(p.getName(), p.getContent().substring(p.getContentBegin(), p.getContentEnd())));
|
3770
|
+
}
|
3771
|
+
else if(iEvt == XMLP._CDATA) { // CDATA Event
|
3772
|
+
// get CDATA data
|
3773
|
+
pContent = p.getContent().substring(p.getContentBegin(), p.getContentEnd());
|
3774
|
+
|
3775
|
+
if (!impl.preserveWhiteSpace) {
|
3776
|
+
pContent = trim(pContent, true, true); // trim whitespace
|
3777
|
+
pContent.replace(/ +/g, ' '); // collapse multiple spaces to 1 space
|
3778
|
+
}
|
3779
|
+
|
3780
|
+
if (pContent.length > 0) { // ignore empty CDATANodes
|
3781
|
+
iNodeParent.appendChild(doc.createCDATASection(pContent)); // attach CDATA to parentNode
|
3782
|
+
}
|
3783
|
+
}
|
3784
|
+
else if(iEvt == XMLP._COMMENT) { // Comment Event
|
3785
|
+
// get COMMENT data
|
3786
|
+
var pContent = p.getContent().substring(p.getContentBegin(), p.getContentEnd());
|
3787
|
+
|
3788
|
+
if (!impl.preserveWhiteSpace) {
|
3789
|
+
pContent = trim(pContent, true, true); // trim whitespace
|
3790
|
+
pContent.replace(/ +/g, ' '); // collapse multiple spaces to 1 space
|
3791
|
+
}
|
3792
|
+
|
3793
|
+
if (pContent.length > 0) { // ignore empty CommentNodes
|
3794
|
+
iNodeParent.appendChild(doc.createComment(pContent)); // attach Comment to parentNode
|
3795
|
+
}
|
3796
|
+
}
|
3797
|
+
else if(iEvt == XMLP._DTD) { // ignore DTD events
|
3798
|
+
}
|
3799
|
+
else if(iEvt == XMLP._ERROR) {
|
3800
|
+
$error("Fatal Error: " + p.getContent() +
|
3801
|
+
"\nLine: " + p.getLineNumber() +
|
3802
|
+
"\nColumn: " + p.getColumnNumber() + "\n");
|
3803
|
+
throw(new DOMException(DOMException.SYNTAX_ERR));
|
3804
|
+
}
|
3805
|
+
else if(iEvt == XMLP._NONE) { // no more events
|
3806
|
+
//steven woods notes that unclosed tags are rejected elsewhere and this check
|
3807
|
+
//breaks a table patching routine
|
3808
|
+
//if (iNodeParent == doc) { // confirm that we have recursed back up to root
|
3809
|
+
// break;
|
3810
|
+
//}
|
3811
|
+
//else {
|
3812
|
+
// throw(new DOMException(DOMException.SYNTAX_ERR)); // one or more Tags were not closed properly
|
3813
|
+
//}
|
3814
|
+
break;
|
3815
|
+
|
3816
|
+
}
|
3817
|
+
}
|
3818
|
+
|
3819
|
+
//normalize any entities in the DOM to a single textNode
|
3820
|
+
for (var i = 0; i < entitiesList.length; i++) {
|
3821
|
+
var entity = entitiesList[i];
|
3822
|
+
//its possible (if for example two entities were in the
|
3823
|
+
//same domnode, that the normalize on the first entitiy
|
3824
|
+
//will remove the parent for the second. Only do normalize
|
3825
|
+
//if I can find a parent node
|
3826
|
+
var parentNode = entity.parentNode;
|
3827
|
+
if (parentNode) {
|
3828
|
+
parentNode.normalize();
|
3829
|
+
|
3830
|
+
//now do whitespace (if necessary)
|
3831
|
+
//it was not done for text nodes that have entities
|
3832
|
+
if(!impl.preserveWhiteSpace) {
|
3833
|
+
var children = parentNode.childNodes;
|
3834
|
+
for ( var j = 0; j < children.length; j++) {
|
3835
|
+
var child = children.item(j);
|
3836
|
+
if (child.nodeType == DOMNode.TEXT_NODE) {
|
3837
|
+
var childData = child.data;
|
3838
|
+
childData.replace(/\s/g, ' ');
|
3839
|
+
child.data = childData;
|
3840
|
+
}
|
3841
|
+
}
|
3842
|
+
}
|
3843
|
+
}
|
3844
|
+
}
|
3845
|
+
|
3846
|
+
//do the preserve whitespace processing on the rest of the text nodes
|
3847
|
+
//It's possible (due to the processing above) that the node will have been
|
3848
|
+
//removed from the tree. Only do whitespace checking if parentNode is not null.
|
3849
|
+
//This may duplicate the whitespace processing for some nodes that had entities in them
|
3850
|
+
//but there's no way around that
|
3851
|
+
if (!impl.preserveWhiteSpace) {
|
3852
|
+
for (var i = 0; i < textNodesList.length; i++) {
|
3853
|
+
var node = textNodesList[i];
|
3854
|
+
if (node.parentNode != null) {
|
3855
|
+
var nodeData = node.data;
|
3856
|
+
nodeData.replace(/\s/g, ' ');
|
3857
|
+
node.data = nodeData;
|
3858
|
+
}
|
3859
|
+
}
|
3860
|
+
|
3861
|
+
}
|
3862
|
+
};
|
3863
|
+
|
3864
|
+
|
3865
|
+
|
3866
|
+
|
3505
3867
|
/**
|
3506
3868
|
* @class DOMDocument - The Document interface represents the entire HTML
|
3507
3869
|
* or XML document. Conceptually, it is the root of the document tree,
|
@@ -3579,11 +3941,14 @@ __extend__(DOMDocument.prototype, {
|
|
3579
3941
|
// create SAX Parser
|
3580
3942
|
var parser = new XMLP(xmlString+'');
|
3581
3943
|
|
3944
|
+
/*
|
3582
3945
|
// create DOM Document
|
3583
3946
|
if(this === $document){
|
3584
3947
|
$debug("Setting internal window.document");
|
3585
3948
|
$document = this;
|
3586
3949
|
}
|
3950
|
+
*/
|
3951
|
+
|
3587
3952
|
// populate Document with Parsed Nodes
|
3588
3953
|
try {
|
3589
3954
|
// make sure thid document object is empty before we try to load ...
|
@@ -3965,10 +4330,12 @@ print("xpath failure: " + e);
|
|
3965
4330
|
},
|
3966
4331
|
get defaultView(){
|
3967
4332
|
var doc = this;
|
3968
|
-
return {
|
3969
|
-
|
3970
|
-
|
3971
|
-
|
4333
|
+
return {
|
4334
|
+
document: this,
|
4335
|
+
getComputedStyle: function(elem){
|
4336
|
+
return doc._parentWindow.getComputedStyle(elem);
|
4337
|
+
}};
|
4338
|
+
},
|
3972
4339
|
_genId : function() {
|
3973
4340
|
this._lastId += 1; // increment lastId (to generate unique id)
|
3974
4341
|
return this._lastId;
|
@@ -4047,6 +4414,109 @@ function __parseQName__(qualifiedName) {
|
|
4047
4414
|
return resultQName;
|
4048
4415
|
};
|
4049
4416
|
|
4417
|
+
/**
|
4418
|
+
* @method DOMImplementation._isNamespaceDeclaration - Return true, if attributeName is a namespace declaration
|
4419
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
4420
|
+
* @param attributeName : string - the attribute name
|
4421
|
+
* @return : boolean
|
4422
|
+
*/
|
4423
|
+
function __isNamespaceDeclaration__(attributeName) {
|
4424
|
+
// test if attributeName is 'xmlns'
|
4425
|
+
return (attributeName.indexOf('xmlns') > -1);
|
4426
|
+
};
|
4427
|
+
|
4428
|
+
/**
|
4429
|
+
* @method DOMImplementation._isIdDeclaration - Return true, if attributeName is an id declaration
|
4430
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
4431
|
+
* @param attributeName : string - the attribute name
|
4432
|
+
* @return : boolean
|
4433
|
+
*/
|
4434
|
+
function __isIdDeclaration__(attributeName) {
|
4435
|
+
// test if attributeName is 'id' (case insensitive)
|
4436
|
+
return attributeName?(attributeName.toLowerCase() == 'id'):false;
|
4437
|
+
};
|
4438
|
+
|
4439
|
+
/**
|
4440
|
+
* @method DOMImplementation._isValidName - Return true,
|
4441
|
+
* if name contains no invalid characters
|
4442
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
4443
|
+
* @param name : string - the candidate name
|
4444
|
+
* @return : boolean
|
4445
|
+
*/
|
4446
|
+
function __isValidName__(name) {
|
4447
|
+
// test if name contains only valid characters
|
4448
|
+
return name.match(re_validName);
|
4449
|
+
};
|
4450
|
+
var re_validName = /^[a-zA-Z_:][a-zA-Z0-9\.\-_:]*$/;
|
4451
|
+
|
4452
|
+
/**
|
4453
|
+
* @method DOMImplementation._isValidString - Return true, if string does not contain any illegal chars
|
4454
|
+
* All of the characters 0 through 31 and character 127 are nonprinting control characters.
|
4455
|
+
* With the exception of characters 09, 10, and 13, (Ox09, Ox0A, and Ox0D)
|
4456
|
+
* Note: different from _isValidName in that ValidStrings may contain spaces
|
4457
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
4458
|
+
* @param name : string - the candidate string
|
4459
|
+
* @return : boolean
|
4460
|
+
*/
|
4461
|
+
function __isValidString__(name) {
|
4462
|
+
// test that string does not contains invalid characters
|
4463
|
+
return (name.search(re_invalidStringChars) < 0);
|
4464
|
+
};
|
4465
|
+
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/;
|
4466
|
+
|
4467
|
+
/**
|
4468
|
+
* @method DOMImplementation._parseNSName - parse the namespace name.
|
4469
|
+
* if there is no colon, the
|
4470
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
4471
|
+
* @param qualifiedName : string - The qualified name
|
4472
|
+
* @return : NSName - [
|
4473
|
+
.prefix : string - The prefix part of the qname
|
4474
|
+
.namespaceName : string - The namespaceURI part of the qname
|
4475
|
+
]
|
4476
|
+
*/
|
4477
|
+
function __parseNSName__(qualifiedName) {
|
4478
|
+
var resultNSName = new Object();
|
4479
|
+
|
4480
|
+
resultNSName.prefix = qualifiedName; // unless the qname has a namespaceName, the prefix is the entire String
|
4481
|
+
resultNSName.namespaceName = "";
|
4482
|
+
|
4483
|
+
// split on ':'
|
4484
|
+
var delimPos = qualifiedName.indexOf(':');
|
4485
|
+
if (delimPos > -1) {
|
4486
|
+
// get prefix
|
4487
|
+
resultNSName.prefix = qualifiedName.substring(0, delimPos);
|
4488
|
+
// get namespaceName
|
4489
|
+
resultNSName.namespaceName = qualifiedName.substring(delimPos +1, qualifiedName.length);
|
4490
|
+
}
|
4491
|
+
return resultNSName;
|
4492
|
+
};
|
4493
|
+
|
4494
|
+
/**
|
4495
|
+
* @method DOMImplementation._parseQName - parse the qualified name
|
4496
|
+
* @author Jon van Noort (jon@webarcana.com.au)
|
4497
|
+
* @param qualifiedName : string - The qualified name
|
4498
|
+
* @return : QName
|
4499
|
+
*/
|
4500
|
+
function __parseQName__(qualifiedName) {
|
4501
|
+
var resultQName = new Object();
|
4502
|
+
|
4503
|
+
resultQName.localName = qualifiedName; // unless the qname has a prefix, the local name is the entire String
|
4504
|
+
resultQName.prefix = "";
|
4505
|
+
|
4506
|
+
// split on ':'
|
4507
|
+
var delimPos = qualifiedName.indexOf(':');
|
4508
|
+
|
4509
|
+
if (delimPos > -1) {
|
4510
|
+
// get prefix
|
4511
|
+
resultQName.prefix = qualifiedName.substring(0, delimPos);
|
4512
|
+
|
4513
|
+
// get localName
|
4514
|
+
resultQName.localName = qualifiedName.substring(delimPos +1, qualifiedName.length);
|
4515
|
+
}
|
4516
|
+
|
4517
|
+
return resultQName;
|
4518
|
+
};
|
4519
|
+
|
4050
4520
|
// $w.Document = DOMDocument;
|
4051
4521
|
|
4052
4522
|
// Local Variables:
|
@@ -4532,6 +5002,7 @@ __extend__(HTMLElement.prototype, {
|
|
4532
5002
|
},
|
4533
5003
|
offsetLeft: 0,
|
4534
5004
|
offsetRight: 0,
|
5005
|
+
offsetTop: 0,
|
4535
5006
|
get offsetParent(){
|
4536
5007
|
/* TODO */
|
4537
5008
|
return;
|
@@ -4540,6 +5011,7 @@ __extend__(HTMLElement.prototype, {
|
|
4540
5011
|
/* TODO */
|
4541
5012
|
return;
|
4542
5013
|
},
|
5014
|
+
scrollTop: 0,
|
4543
5015
|
scrollHeight: 0,
|
4544
5016
|
scrollWidth: 0,
|
4545
5017
|
scrollLeft: 0,
|
@@ -6119,7 +6591,7 @@ var __param__= function( array, boundary ) {
|
|
6119
6591
|
array[i].value.push(content);
|
6120
6592
|
array[i].value = array[i].value.join("\r\n");
|
6121
6593
|
}
|
6122
|
-
serialized.push('Content-Disposition: form-data; name="'+array[i].name+'"'+fn+'\r\n');
|
6594
|
+
serialized.push('Content-Disposition: form-data; name="'+array[i].name+'"'+fn+'\r\n\r\n');
|
6123
6595
|
serialized.push(array[i].value);
|
6124
6596
|
serialized.push( "\r\n" );
|
6125
6597
|
}
|
@@ -19679,6 +20151,7 @@ function TokenExpr(m) {
|
|
19679
20151
|
}
|
19680
20152
|
|
19681
20153
|
TokenExpr.prototype.evaluate = function() {
|
20154
|
+
// print("0 "+arguments.callee+" "+this.value);
|
19682
20155
|
return new StringValue(this.value);
|
19683
20156
|
};
|
19684
20157
|
|
@@ -19969,12 +20442,14 @@ function NodeTestAny() {
|
|
19969
20442
|
}
|
19970
20443
|
|
19971
20444
|
NodeTestAny.prototype.evaluate = function(ctx) {
|
20445
|
+
// print("0 "+arguments.callee);
|
19972
20446
|
return this.value;
|
19973
20447
|
};
|
19974
20448
|
|
19975
20449
|
function NodeTestElementOrAttribute() {}
|
19976
20450
|
|
19977
20451
|
NodeTestElementOrAttribute.prototype.evaluate = function(ctx) {
|
20452
|
+
// print("0 "+arguments.callee);
|
19978
20453
|
return new BooleanValue(
|
19979
20454
|
ctx.node.nodeType == DOMNode.ELEMENT_NODE ||
|
19980
20455
|
ctx.node.nodeType == DOMNode.ATTRIBUTE_NODE);
|
@@ -19983,12 +20458,14 @@ NodeTestElementOrAttribute.prototype.evaluate = function(ctx) {
|
|
19983
20458
|
function NodeTestText() {}
|
19984
20459
|
|
19985
20460
|
NodeTestText.prototype.evaluate = function(ctx) {
|
20461
|
+
// print("0 "+arguments.callee);
|
19986
20462
|
return new BooleanValue(ctx.node.nodeType == DOMNode.TEXT_NODE);
|
19987
20463
|
}
|
19988
20464
|
|
19989
20465
|
function NodeTestComment() {}
|
19990
20466
|
|
19991
20467
|
NodeTestComment.prototype.evaluate = function(ctx) {
|
20468
|
+
// print("0 "+arguments.callee);
|
19992
20469
|
return new BooleanValue(ctx.node.nodeType == DOMNode.COMMENT_NODE);
|
19993
20470
|
}
|
19994
20471
|
|
@@ -19997,6 +20474,7 @@ function NodeTestPI(target) {
|
|
19997
20474
|
}
|
19998
20475
|
|
19999
20476
|
NodeTestPI.prototype.evaluate = function(ctx) {
|
20477
|
+
// print("0 "+arguments.callee);
|
20000
20478
|
return new
|
20001
20479
|
BooleanValue(ctx.node.nodeType == DOMNode.PROCESSING_INSTRUCTION_NODE &&
|
20002
20480
|
(!this.target || ctx.node.nodeName == this.target));
|
@@ -20008,6 +20486,7 @@ function NodeTestNC(nsprefix) {
|
|
20008
20486
|
}
|
20009
20487
|
|
20010
20488
|
NodeTestNC.prototype.evaluate = function(ctx) {
|
20489
|
+
// print("0 "+arguments.callee);
|
20011
20490
|
var n = ctx.node;
|
20012
20491
|
return new BooleanValue(this.regex.match(n.nodeName));
|
20013
20492
|
}
|
@@ -20018,6 +20497,7 @@ function NodeTestName(name) {
|
|
20018
20497
|
}
|
20019
20498
|
|
20020
20499
|
NodeTestName.prototype.evaluate = function(ctx) {
|
20500
|
+
// print("0 !!! "+arguments.callee);
|
20021
20501
|
var n = ctx.node;
|
20022
20502
|
if (ctx.caseInsensitive || n instanceof HTMLElement) {
|
20023
20503
|
if (n.nodeName.length != this.name.length) return new BooleanValue(false);
|
@@ -20032,6 +20512,7 @@ function PredicateExpr(expr) {
|
|
20032
20512
|
}
|
20033
20513
|
|
20034
20514
|
PredicateExpr.prototype.evaluate = function(ctx) {
|
20515
|
+
// print("0 "+arguments.callee);
|
20035
20516
|
var v = this.expr.evaluate(ctx);
|
20036
20517
|
if (v.type == 'number') {
|
20037
20518
|
// NOTE(mesch): Internally, position is represented starting with
|
@@ -20053,9 +20534,11 @@ FunctionCallExpr.prototype.appendArg = function(arg) {
|
|
20053
20534
|
};
|
20054
20535
|
|
20055
20536
|
FunctionCallExpr.prototype.evaluate = function(ctx) {
|
20537
|
+
// print("0 "+arguments.callee+" "+this.name.value);
|
20056
20538
|
var fn = '' + this.name.value;
|
20057
20539
|
var f = this.xpathfunctions[fn];
|
20058
20540
|
if (f) {
|
20541
|
+
// print("1 "+f);
|
20059
20542
|
return f.call(this, ctx);
|
20060
20543
|
} else {
|
20061
20544
|
xpathLog('XPath NO SUCH FUNCTION ' + fn);
|
@@ -20129,6 +20612,9 @@ FunctionCallExpr.prototype.xpathfunctions = {
|
|
20129
20612
|
if (n.length == 0) {
|
20130
20613
|
return new StringValue('');
|
20131
20614
|
} else {
|
20615
|
+
if (ctx.caseInsensitive || n[0] instanceof HTMLElement) {
|
20616
|
+
return new StringValue(n[0].nodeName.toLowerCase());
|
20617
|
+
}
|
20132
20618
|
return new StringValue(n[0].nodeName);
|
20133
20619
|
}
|
20134
20620
|
},
|
@@ -20406,6 +20892,7 @@ function UnionExpr(expr1, expr2) {
|
|
20406
20892
|
}
|
20407
20893
|
|
20408
20894
|
UnionExpr.prototype.evaluate = function(ctx) {
|
20895
|
+
// print("0 "+arguments.callee);
|
20409
20896
|
var nodes1 = this.expr1.evaluate(ctx).nodeSetValue();
|
20410
20897
|
var nodes2 = this.expr2.evaluate(ctx).nodeSetValue();
|
20411
20898
|
var I1 = nodes1.length;
|
@@ -20431,6 +20918,7 @@ function PathExpr(filter, rel) {
|
|
20431
20918
|
}
|
20432
20919
|
|
20433
20920
|
PathExpr.prototype.evaluate = function(ctx) {
|
20921
|
+
// print("0 "+arguments.callee);
|
20434
20922
|
var nodes = this.filter.evaluate(ctx).nodeSetValue();
|
20435
20923
|
var nodes1 = [];
|
20436
20924
|
if (ctx.returnOnFirstMatch) {
|
@@ -20459,6 +20947,7 @@ function FilterExpr(expr, predicate) {
|
|
20459
20947
|
}
|
20460
20948
|
|
20461
20949
|
FilterExpr.prototype.evaluate = function(ctx) {
|
20950
|
+
// print("0 "+arguments.callee);
|
20462
20951
|
// the filter expression should be evaluated in its entirety with no
|
20463
20952
|
// optimization, as we can't backtrack to it after having moved on to
|
20464
20953
|
// evaluating the relative location path. See the testReturnOnFirstMatch
|
@@ -20487,6 +20976,7 @@ function UnaryMinusExpr(expr) {
|
|
20487
20976
|
}
|
20488
20977
|
|
20489
20978
|
UnaryMinusExpr.prototype.evaluate = function(ctx) {
|
20979
|
+
// print("0 "+arguments.callee);
|
20490
20980
|
return new NumberValue(-this.expr.evaluate(ctx).numberValue());
|
20491
20981
|
};
|
20492
20982
|
|
@@ -20497,6 +20987,7 @@ function BinaryExpr(expr1, op, expr2) {
|
|
20497
20987
|
}
|
20498
20988
|
|
20499
20989
|
BinaryExpr.prototype.evaluate = function(ctx) {
|
20990
|
+
// print("0 "+arguments.callee);
|
20500
20991
|
var ret;
|
20501
20992
|
switch (this.op.value) {
|
20502
20993
|
case 'or':
|
@@ -20661,6 +21152,7 @@ function LiteralExpr(value) {
|
|
20661
21152
|
}
|
20662
21153
|
|
20663
21154
|
LiteralExpr.prototype.evaluate = function(ctx) {
|
21155
|
+
// print("0 "+arguments.callee+" "+this.value);
|
20664
21156
|
return new StringValue(this.value);
|
20665
21157
|
};
|
20666
21158
|
|
@@ -20669,6 +21161,7 @@ function NumberExpr(value) {
|
|
20669
21161
|
}
|
20670
21162
|
|
20671
21163
|
NumberExpr.prototype.evaluate = function(ctx) {
|
21164
|
+
// print("0 "+arguments.callee);
|
20672
21165
|
return new NumberValue(this.value);
|
20673
21166
|
};
|
20674
21167
|
|
@@ -20677,6 +21170,7 @@ function VariableExpr(name) {
|
|
20677
21170
|
}
|
20678
21171
|
|
20679
21172
|
VariableExpr.prototype.evaluate = function(ctx) {
|
21173
|
+
// print("0 "+arguments.callee);
|
20680
21174
|
return ctx.getVariable(this.name);
|
20681
21175
|
}
|
20682
21176
|
|
@@ -22139,7 +22633,7 @@ __extend__(CSS2Properties.prototype, {
|
|
22139
22633
|
get cssText(){
|
22140
22634
|
var css = '';
|
22141
22635
|
for(var i=0;i<this.length;i++){
|
22142
|
-
css+=this[i]+":"+this.getPropertyValue(this[i])+';'
|
22636
|
+
css+=this[i]+":"+this.getPropertyValue(this[i])+';';
|
22143
22637
|
}
|
22144
22638
|
return css;
|
22145
22639
|
},
|
@@ -22293,7 +22787,7 @@ var __supportedStyles__ = function(){
|
|
22293
22787
|
fontVariant: null,
|
22294
22788
|
fontWeight: null,
|
22295
22789
|
height: '1px',
|
22296
|
-
left:
|
22790
|
+
left: '0px',
|
22297
22791
|
letterSpacing: null,
|
22298
22792
|
lineHeight: null,
|
22299
22793
|
listStyle: null,
|
@@ -22352,7 +22846,7 @@ var __supportedStyles__ = function(){
|
|
22352
22846
|
textIndent: null,
|
22353
22847
|
textShadow: null,
|
22354
22848
|
textTransform: null,
|
22355
|
-
top:
|
22849
|
+
top: '0px',
|
22356
22850
|
unicodeBidi: null,
|
22357
22851
|
verticalAlign: null,
|
22358
22852
|
visibility: null,
|
@@ -22577,10 +23071,12 @@ get cookie(c){
|
|
22577
23071
|
//case we must check our current location.protocol to make sure it's
|
22578
23072
|
//https:
|
22579
23073
|
var allcookies = [], i;
|
22580
|
-
|
23074
|
+
return cookieString.call(this, $cookies.temporary) +
|
23075
|
+
cookieString.call(this, $cookies.persistent);
|
22581
23076
|
}});
|
22582
23077
|
|
22583
23078
|
var cookieString = function(cookies) {
|
23079
|
+
var $w = this._parentWindow;
|
22584
23080
|
var cookieString = "";
|
22585
23081
|
for (var i in cookies) {
|
22586
23082
|
// check if the cookie is in the current domain (if domain is set)
|