Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

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

$
0
0
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.

Attachment 5981

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!

Attached Images
File Type: png Screen Shot 2013-07-19 at 09.56.13.png (3.9 KB)

Viewing all articles
Browse latest Browse all 4756

Trending Articles