Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    [bug] isc.Element._getElementFromSelection causes unspecified error in IE

    Version: v8.3p_2013-06-01/PowerEdition Deployment
    Browser: Embedded .net control (IE8 installed on XPSP3)

    Re-creating this will not be easy, but my proposed fix does work in my case!

    We have a window with an embedded .net control that is displaying a SmartClient page that has a DynamicForm with an UploadItem in it. The window pops up and the page loads immediately.

    [ATTACH]5981[/ATTACH]

    The bug: if the first thing the user clicks on in the browser control is either the 'Browse...' button or the rectangle immediately to the left of the 'Browse...' button, then they get a JS 'Unspecified error'.

    If they click anywhere else on the page first and then click the 'Browse...' button, they don't get the error.

    I traced the code back to:

    Code:
    _getElementFromSelection : function (doc) {
        if (!doc) doc = document;
    
        if (isc.Browser.isIE ) {
            var selection = doc.selection,
                type = selection.type.toLowerCase(),
                isText = (type == "text" || type == "none");
    Very strangely, it seems to be the actual accessing of the selection.type that causes the error to be thrown.

    If I insert

    Code:
    alert(isc.getKeys(doc.selection));
    I can see that the 'type' key exists, but if I insert

    Code:
    alert(isc.getValues(doc.selection));
    then I get the error thrown.

    I broke the var statement into separate lines to confirm where the error was being thrown:

    Code:
    _getElementFromSelection : function (doc) {
        if (!doc) doc = document;
    
        if (isc.Browser.isIE ) {
    
            // alert(isc.getKeys(doc.selection)); // works
            // alert(isc.getValues(doc.selection)); // throws error
    
            var selection = doc.selection;
            var type = selection.type; // This is the line that throws the error
            type = type.toLowerCase();
            var isText = (type == "text" || type == "none");
    Googling 'document.selection.type unspecified error' I found:

    http://dev.ckeditor.com/ticket/9034

    Which seemed to be related.

    In the end, their solution of wrapping in a try catch worked:

    Code:
        if (isc.Browser.isIE ) {
    
            var selection = doc.selection;
            try {
                var type = selection.type.toLowerCase();
            } catch(err) {
                return null;
            }
            var isText = (type == "text" || type == "none");
    I have wrapped the whole of obfuscated isc.Element.$mk in a try catch so as to avoid problems when upgrading SmartClient, but I'd love if you were to incorporate a fix into the source code!

    #2
    Thanks for the clear description and useful link to the CKEditor thread on this.
    We've gone ahead and incorporated the try...catch block fix to _getElementFromSelection() in the 9.0p and 9.1d branches. It'll show up in nightly builds there going forward

    Regards
    Isomorphic Software

    Comment


      #3
      Thanks, that works.

      Comment

      Working...
      X