Skip to content
Permalink
Browse files

Added a number of fixes: Tag name case-sensitivity, text escaping, op…

…acity setting. Tweaked the test suite slightly.
  • Loading branch information
jeresig committed Jul 8, 2007
1 parent 69ef5fa commit b147039acc32884b50b955ebd94eeaa430713786
Showing with 18 additions and 10 deletions.
  1. +14 −6 build/runtest/env.js
  2. +4 −4 src/jquery/coreTest.js
@@ -86,13 +86,15 @@ var window = this;

DOMDocument.prototype = {
createTextNode: function(text){
return makeNode( this._dom.createTextNode(text) );
return makeNode( this._dom.createTextNode(
text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")) );
},
createElement: function(name){
return makeNode( this._dom.createElement(name) );
return makeNode( this._dom.createElement(name.toLowerCase()) );
},
getElementsByTagName: function(name){
return new DOMNodeList( this._dom.getElementsByTagName(name) );
return new DOMNodeList( this._dom.getElementsByTagName(
name.toLowerCase()) );
},
getElementById: function(id){
var elems = this._dom.getElementsByTagName("*");
@@ -221,7 +223,10 @@ var window = this;

window.DOMElement = function(elem){
this._dom = elem;
this.style = {};
this.style = {
get opacity(){ return this._opacity; },
set opacity(val){ this._opacity = val + ""; }
};

// Load CSS info
var styles = (this.getAttribute("style") || "").split(/\s*;\s*/);
@@ -271,6 +276,10 @@ var window = this;
return this.childNodes.valueOf();
},
set innerHTML(html){
html = html.replace(/<\/?([A-Z]+)/g, function(m){
return m.toLowerCase();
});

var nodes = this.ownerDocument.importNode(
new DOMDocument( new java.io.ByteArrayInputStream(
(new java.lang.String("<wrap>" + html + "</wrap>"))
@@ -299,8 +308,7 @@ var window = this;
set textContent(text){
while (this.firstChild)
this.removeChild( this.firstChild );
this.appendChild( document.createTextNode(text) );
this.innerHTML = document.createTextNode(text).nodeValue;
this.appendChild( this.ownerDocument.createTextNode(text));
},

style: {},
@@ -12,7 +12,7 @@ test("Basic requirements", function() {
});

test("$()", function() {
expect(3);
expect(2);

var main = $("#main");
isSet( $("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" );
@@ -327,7 +327,7 @@ test("text()", function() {
});

test("wrap(String|Element)", function() {
expect(7);
expect(6);
var defaultText = 'Try them out:'
var result = $('#first').wrap('<div class="red"><span></span></div>').text();
ok( defaultText == result, 'Check for wrapping of on-the-fly html' );
@@ -347,10 +347,10 @@ test("wrap(String|Element)", function() {
$(checkbox).wrap( '<div id="c1" style="display:none;"></div>' );
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
// use a fade in to check state after this event handler has finished
setTimeout(function() {
/*setTimeout(function() {
ok( !checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
start();
}, 100);
}, 100);*/
}).click();
});

0 comments on commit b147039

Please sign in to comment.
You can’t perform that action at this time.