Opened 7 years ago

Closed 7 years ago

#408 closed defect (fixed)

IE9-beta createElement fix

Reported by: madair Owned by: madair
Priority: P2 Milestone: 2.2
Component: Core Version: 2.0 - beta
Severity: Minor Keywords:
Cc: Browser: Other
External ID: Operating System: All
state: New

Description

This patch to be applied to the 2.2 branch, 2.3 will have the fix from Mootools.

from Ted Yang:

I’m working on IE9 support from Autodesk, and I found one defect in JxLib, this is because IE9 beta works different with IE8.

var a = document.createElement("<div>");

this code works on IE8, but not works on IE9 beta;(Note that if the web page is quite simple, the IE9 will run the page on “Quirks mode” and this code will work, but in most standard webpage this code doesn’t work)

var a = document.createElement("div");

this code works on IE9 beta, but not works on IE8;

so we suggest to fix it in JxLib’s code, and I wish someone can review it and submit it before Oct. 1th.

Original code:

Document.implement({

newElement: function(tag, props) {

if (Browser.Engine.trident && props) {

['name', 'type', 'checked'].each(function(attribute) {

if (!props[attribute]) return;

tag += ' ' + attribute + '="' + props[attribute] + '"';

if (attribute != 'checked') delete props[attribute];

});

tag = '<' + tag + '>';

}

return $.element(this.createElement(tag)).set(props);

},

newTextNode: function(text) {

return this.createTextNode(text);

},

getDocument: function() {

return this;

},

getWindow: function() {

return this.window;

}

});

Fixed code(our solution, tested on IE9 beta):

document.newElement = function(tag, props) {

var createdElement;

if (Browser.Engine.trident && props) {

['name', 'type', 'checked'].each(function(attribute) {

if (!props[attribute]) return;

tag += ' ' + attribute + '="' + props[attribute] + '"';

if (attribute != 'checked') delete props[attribute];

});

var replaceTag = '<' + tag + '>';

try {

createdElement = this.createElement(replaceTag);

}

catch (e) {

createdElement = this.createElement(tag);

}

}

else {

createdElement = this.createElement(tag);

}

return $.element(createdElement).set(props);

};

Change History (1)

comment:1 Changed 7 years ago by madair

Component: WidgetsCore
Resolution: fixed
Status: newclosed

fixed at rev [2360] in the 2.2 branch.

Note: See TracTickets for help on using tickets.