Changeset 1233


Ignore:
Timestamp:
01/31/10 11:43:35 (10 years ago)
Author:
gogo
Message:

TIcket #1488 fix Control Selection in IE8

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/InternetExplorer/InternetExplorer.js

    r1207 r1233  
    468468  // object does not implement parentElement(), leading to a crash later on in the code below.  The following  
    469469  // hack avoids that problem.  
    470   if (!savedSelection.parentElement)  
    471   { 
    472     return; 
    473   }  
     470   
     471  // Ticket #1488 
     472  // fix control selection in IE8 
     473   
     474  var savedParentElement = null; 
     475  if (savedSelection.parentElement) 
     476  { 
     477    savedParentElement =  savedSelection.parentElement(); 
     478  } 
     479  else 
     480  { 
     481    savedParentElement = savedSelection.item(0); 
     482  } 
    474483   
    475484  // In order to prevent triggering the IE bug mentioned below, we will try to 
     
    478487  var range = this.createRange(this.getSelection()); 
    479488 
     489  var rangeParentElement =  null; 
     490  if (range.parentElement) 
     491  { 
     492    rangeParentElement =  range.parentElement(); 
     493  } 
     494  else 
     495  { 
     496    rangeParentElement = range.item(0); 
     497  } 
     498 
    480499  // We can't compare two selections that come from different documents, so we 
    481500  // must make sure they're from the same document. 
     
    492511  } 
    493512 
    494   if (findDoc(savedSelection.parentElement()) == findDoc(range.parentElement())) 
     513  if (savedSelection.parentElement && findDoc(savedParentElement) == findDoc(rangeParentElement)) 
    495514  { 
    496515    if (range.isEqual(savedSelection)) 
     
    503522  try { savedSelection.select() } catch (e) {}; 
    504523  range = this.createRange(this.getSelection()); 
    505   if (range.parentElement() != savedSelection.parentElement()) 
     524   
     525  if (range.parentElement) 
     526  { 
     527    rangeParentElement =  range.parentElement(); 
     528  } 
     529  else 
     530  { 
     531    rangeParentElement = range.item(0); 
     532  } 
     533   
     534  if (rangeParentElement != savedParentElement) 
    506535  { 
    507536    // IE has a problem with selections at the end of text nodes that 
     
    523552        // This workaround inserts an empty span element so that we are no 
    524553        // longer trying to select a text node, 
    525         var parentDoc = findDoc(savedSelection.parentElement()); 
     554        var parentDoc = findDoc(savedParentElement); 
    526555 
    527556        // A function used to generate a unique ID for our temporary span. 
Note: See TracChangeset for help on using the changeset viewer.