Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:thatcher/env-js
Browse files Browse the repository at this point in the history
  • Loading branch information
gleneivey committed Nov 14, 2009
2 parents 5f9a9eb + 4eabf20 commit 9376070
Show file tree
Hide file tree
Showing 10 changed files with 312 additions and 298 deletions.
149 changes: 82 additions & 67 deletions dist/env.js
Expand Up @@ -160,7 +160,10 @@ __extend__($w,{
get status(){return $status;},
set status(_status){$status = _status;},
get top(){return $top || $window;},
get window(){return $window;}
get window(){return $window;},
toString : function(){
return '[object Window]';
}
});

$w.open = function(url, name, features, replace){
Expand Down Expand Up @@ -1687,8 +1690,7 @@ __extend__(DOMText.prototype,{
return DOMNode.TEXT_NODE;
},
get xml(){
return __escapeXML__(""+ this.nodeValue);
//return ""+ this.nodeValue;
return __escapeHTML5__(""+ this.nodeValue);
},
toString: function(){
return "Text #" + this._id;
Expand Down Expand Up @@ -1809,7 +1811,7 @@ __extend__(DOMAttr.prototype, {
},
get xml(){
if(this.nodeValue)
return this.nodeName + '="' + __escapeXML__(this.nodeValue+"") + '" ';
return ' '+this.nodeName + '="' + __escapeXML__(this.nodeValue+"") + '"';
else
return '';
},
Expand Down Expand Up @@ -2011,7 +2013,7 @@ __extend__(DOMElement.prototype, {

// serialize Attribute declarations
var attrs = this.attributes.xml;
if (attrs.length > 0) attrs = " "+ attrs;
if (attrs.length > 0) attrs = ""+ attrs;

// serialize this Element
ret += "<" + this.nodeName.toLowerCase() + ns + attrs +">";
Expand Down Expand Up @@ -2206,7 +2208,7 @@ var whitespace = "\n\r\t ";
**/


var XMLP = function(strXML) {
/*var XMLP = function(strXML) {
// Normalize line breaks
strXML = SAXStrings.replace(strXML, null, null, "\r\n", "\n");
strXML = SAXStrings.replace(strXML, null, null, "\r", "\n");
Expand Down Expand Up @@ -2602,14 +2604,7 @@ XMLP.prototype._parseDTD = function(iB) {
strClose = ((iInt != -1) && (iInt < iE)) ? "]>" : ">";

while(true) {
// DEBUG: Remove
/*if(iE == iLast) {
return this._setErr(XMLP.ERR_INFINITELOOP);
}

iLast = iE;*/
// DEBUG: Remove End


iE = this.m_xml.indexOf(strClose, iB);
if(iE == -1) {
return this._setErr(XMLP.ERR_CLOSE_DTD);
Expand Down Expand Up @@ -2657,17 +2652,18 @@ XMLP.prototype._parseElement = function(iB) {
//djohack
//hack to allow for elements with single character names to be recognized

/*if (iE - iB != 1 ) {
if(SAXStrings.indexOfNonWhitespace(this.m_xml, iB, iDE) != iB) {
return this._setErr(XMLP.ERR_ELM_NAME);
}
}*/
///if (iE - iB != 1 ) {
/// if(SAXStrings.indexOfNonWhitespace(this.m_xml, iB, iDE) != iB) {
/// return this._setErr(XMLP.ERR_ELM_NAME);
/// }
///}

// end hack -- original code below

/*
if(SAXStrings.indexOfNonWhitespace(this.m_xml, iB, iDE) != iB)
return this._setErr(XMLP.ERR_ELM_NAME);
*/

///if(SAXStrings.indexOfNonWhitespace(this.m_xml, iB, iDE) != iB)
/// return this._setErr(XMLP.ERR_ELM_NAME);
///
this._clearAttributes();

iNE = SAXStrings.indexOfWhitespace(this.m_xml, iB, iDE);
Expand All @@ -2690,9 +2686,9 @@ XMLP.prototype._parseElement = function(iB) {

strN = this.m_xml.substring(iB, iNE);

/*if(strN.indexOf("<") != -1) {
return this._setErr(XMLP.ERR_ELM_LT_NAME);
}*/
///if(strN.indexOf("<") != -1) {
/// return this._setErr(XMLP.ERR_ELM_LT_NAME);
///}s

this.m_name = strN;
this.m_iP = iE + 1;
Expand Down Expand Up @@ -2869,7 +2865,7 @@ XMLP.prototype._setErr = function(iErr) {
return XMLP._ERROR;

}

*/

/**
* function: SAXDriver
Expand All @@ -2879,7 +2875,7 @@ XMLP.prototype._setErr = function(iErr) {
* event-based interface for parsing. This is the object users interact with when coding
* with XML for <SCRIPT>
**/

/*
var SAXDriver = function() {
this.m_hndDoc = null;
this.m_hndErr = null;
Expand Down Expand Up @@ -2947,9 +2943,9 @@ SAXDriver.prototype.setLexicalHandler = function(hnd) {
}


/**
* LOCATOR/PARSE EXCEPTION INTERFACE
***/

/// LOCATOR/PARSE EXCEPTION INTERFACE


SAXDriver.prototype.getColumnNumber = function() {

Expand Down Expand Up @@ -2986,10 +2982,10 @@ SAXDriver.prototype.getSystemId = function() {
}


/***
* Attribute List Interface
**/

/// Attribute List Interface


SAXDriver.prototype.getLength = function() {

return this.m_parser.getAttributeCount();
Expand Down Expand Up @@ -3018,9 +3014,7 @@ SAXDriver.prototype.getValueByName = function(name) {
}


/***
* Private functions
**/
/// Private functions

SAXDriver.prototype._fireError = function(strMsg) {
this.m_strErrMsg = strMsg;
Expand Down Expand Up @@ -3130,11 +3124,11 @@ SAXDriver.prototype._parseLoop = function(parser) {

} // end function _parseLoop

/**
* function: SAXStrings
* Author: Scott Severtson
* Description: a useful object containing string manipulation functions
**/
///
/// function: SAXStrings
/// Author: Scott Severtson
/// Description: a useful object containing string manipulation functions
///

var _SAXStrings = function() {};

Expand Down Expand Up @@ -3182,12 +3176,12 @@ _SAXStrings.prototype.indexOfNonWhitespace = function(strD, iB, iE) {

while( strD.charCodeAt(iB++) < 33 );
return (iB > iE)?-1:iB-1;
/*for(var i = iB; i < iE; i++){
if(_SAXStrings.WHITESPACE.indexOf(strD.charAt(i)) == -1) {
return i;
}
}
return -1;*/
///for(var i = iB; i < iE; i++){
/// if(_SAXStrings.WHITESPACE.indexOf(strD.charAt(i)) == -1) {
/// return i;
/// }
///}
///return -1;

} // end function indexOfNonWhitespace

Expand All @@ -3203,12 +3197,12 @@ _SAXStrings.prototype.indexOfWhitespace = function(strD, iB, iE) {
while( strD.charCodeAt(iB++) >= 33 );
return (iB > iE)?-1:iB-1;

/*for(var i = iB; i < iE; i++) {
if(_SAXStrings.WHITESPACE.indexOf(strD.charAt(i)) != -1) {
return i;
}
}
return -1;*/
///for(var i = iB; i < iE; i++) {
/// if(_SAXStrings.WHITESPACE.indexOf(strD.charAt(i)) != -1) {
/// return i;
/// }
///}
///return -1;
} // end function indexOfWhitespace


Expand All @@ -3229,12 +3223,12 @@ _SAXStrings.prototype.lastIndexOfNonWhitespace = function(strD, iB, iE) {
while( (iE >= iB) && strD.charCodeAt(--iE) < 33 );
return (iE < iB)?-1:iE;

/*for(var i = iE - 1; i >= iB; i--){
if(_SAXStrings.WHITESPACE.indexOf(strD.charAt(i)) == -1){
return i;
}
}
return -1;*/
///for(var i = iE - 1; i >= iB; i--){
/// if(_SAXStrings.WHITESPACE.indexOf(strD.charAt(i)) == -1){
/// return i;
/// }
///}
///return -1;
}


Expand All @@ -3258,7 +3252,7 @@ Stack: A simple stack class, used for verifying document structure.

Author: Scott Severtson
*****************************************************************************************************************/

/*
var Stack = function() {
this.m_arr = new Array();
};
Expand Down Expand Up @@ -3292,15 +3286,15 @@ __extend__(Stack.prototype, {
});


/**
* function: isEmpty
* Author: mike@idle.org
* Description: convenience function to identify an empty string
**/
///
/// function: isEmpty
/// Author: mike@idle.org
/// Description: convenience function to identify an empty string
///
function isEmpty(str) {
return (str==null) || (str.length==0);
};

*/

/**
* function __escapeXML__
Expand All @@ -3322,7 +3316,22 @@ function __escapeXML__(str) {

return str;
};
function __escapeHTML5__(str) {
str = str.replace(escAmpRegEx, "&amp;").
replace(escLtRegEx, "&lt;").
replace(escGtRegEx, "&gt;");

return str;
};
function __escapeHTML5Atribute__(str) {
str = str.replace(escAmpRegEx, "&amp;").
replace(escLtRegEx, "&lt;").
replace(escGtRegEx, "&gt;").
replace(quotRegEx, "&quot;").
replace(aposRegEx, "&apos;");

return str;
};
/**
* function __unescapeXML__
* author: David Joham djoham@yahoo.com
Expand Down Expand Up @@ -4227,6 +4236,9 @@ var DOMDocument = function(implementation, docParentWindow) {
};
DOMDocument.prototype = new DOMNode;
__extend__(DOMDocument.prototype, {
toString : function(){
return '[object HTMLDocument]';
},
addEventListener : function(){ window.addEventListener.apply(this, arguments); },
removeEventListener : function(){ window.removeEventListener.apply(this, arguments); },
attachEvent : function(){ window.addEventListener.apply(this, arguments); },
Expand Down Expand Up @@ -4962,6 +4974,9 @@ var HTMLDocument = function(implementation, docParentWindow, docReferrer) {
};
HTMLDocument.prototype = new DOMDocument;
__extend__(HTMLDocument.prototype, {
toString : function(){
return '[object HTMLDocument]';
},
createElement: function(tagName){
//print('createElement :'+tagName);
// throw Exception if the tagName string contains an illegal character
Expand Down

0 comments on commit 9376070

Please sign in to comment.