[fusion-trac] #408: IE9-beta createElement fix

Fusion trac_fusion at osgeo.org
Wed Sep 29 09:22:51 EDT 2010


#408: IE9-beta createElement fix
-----------------------+----------------------------------------------------
   Reporter:  madair   |       Owner:  madair    
       Type:  defect   |      Status:  new       
   Priority:  P2       |   Milestone:  2.2       
  Component:  Widgets  |     Version:  2.0 - beta
   Severity:  Minor    |    Keywords:            
External_id:           |       State:  New       
    Browser:  Other    |          Os:  All       
-----------------------+----------------------------------------------------
 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);

         };

-- 
Ticket URL: <http://trac.osgeo.org/fusion/ticket/408>
Fusion <http://trac.osgeo.org/fusion>
Fusion is a web-mapping application development framework for MapServer and MapGuide OS.


More information about the fusion-trac mailing list