Skip to main content

Bug Tracker

Side navigation

#14890 closed bug (notabug)

Opened March 14, 2014 06:31AM UTC

Closed March 14, 2014 12:26PM UTC

TypeError: Argument 1 of Window.getDefaultComputedStyle is not an object

Reported by: mr.efrem@gmail.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 2.1.0
Keywords: Cc:
Blocked by: Blocking:
Description

I use hack for support of client-size XSLT:

var defaultNS = document.documentElement.namespaceURI;
/**
 * Use the given object to override the given methods in its prototype
 * with namespace-aware equivalents
 */
function addNS(obj, methods) {
    var proto = obj.constructor.prototype;

    for (var methodName in methods) {
        (function() {
            var methodNS = proto[methodName + "NS"];

            if (methodNS) {
                proto[methodName] = function() {
                    var args = Array.prototype.slice.call(arguments, 0);
                    args.unshift(defaultNS);
                    return methodNS.apply(this, args);
                };
            }
        })();
    }
}

// Play nice with IE -- who doesn't need this hack in the first place
if (document.constructor) {
    // Override document methods that are used by jQuery
    addNS(document, {
        createElement: 1/*,
        getElementsByTagName: 1*/
    });

    // Override element methods that are used by jQuery
    /*addNS(document.createElement("div"), {
        getElementsByTagName: 1,
        getAttribute: 1,
        getAttributeNode: 1,
        removeAttribute: 1,
        setAttribute: 1
    });*/
}

And in funcion get error in line 5422:

"TypeError: Argument 1 of Window.getDefaultComputedStyle is not an object."

function actualDisplay( name, doc ) {
        var elem=jQuery( doc.createElement( name ) ).appendTo( doc.body );

        // getDefaultComputedStyle might be reliably used only on attached element
            display = window.getDefaultComputedStyle ?

                // Use of this method is a temporary fix (more like optmization) until something better comes along,
                // since it was removed from specification and supported only in FF
                window.getDefaultComputedStyle( elem[0] ).display : jQuery.css( elem[0], "display" );

        // We don't have any data stored on the element,
        // so use "detach" method as fast way to get rid of the element
        elem.detach();

        return display;
    }

As for me works:

function actualDisplay( name, doc ) {
        var origElem=doc.createElement( name );
        var elem = jQuery( origElem ).appendTo( doc.body ),

        // getDefaultComputedStyle might be reliably used only on attached element
            display = window.getDefaultComputedStyle ?

                // Use of this method is a temporary fix (more like optmization) until something better comes along,
                // since it was removed from specification and supported only in FF
                window.getDefaultComputedStyle( origElem ).display : jQuery.css( origElem, "display" );

        // We don't have any data stored on the element,
        // so use "detach" method as fast way to get rid of the element
        elem.detach();

        return display;
    }
Attachments (0)
Change History (3)

Changed March 14, 2014 11:35AM UTC by mr.efrem@gmail.com comment:1

I use jquery-ui-autocomplete and get error "TypeError: this.menu is undefined" likely for the same reason. I have a suspicion that a problem in appendTo.

this.menu = $( "<ul>" )
            .addClass( "ui-autocomplete ui-front" )
            .appendTo( this._appendTo() )
			.menu({
				// disable ARIA support, the live region takes care of that
				role: null
			})
			.hide()
			.data( "ui-menu" );

		this._on( this.menu.element, {

Changed March 14, 2014 12:01PM UTC by mr.efrem@gmail.com comment:2

The most interesting that this problem is watched only in Firefox 27.0.1. In Google Chrome 33.0.1750.149 and IE 11.0.1 it isn't present.

Changed March 14, 2014 12:26PM UTC by dmethvin comment:3

resolution: → notabug
status: newclosed

This is the jQuery core bug tracker. Read the page at http://bugs.jquery.com to see what to do next. They'll need a full test case as well, which didn't come with this report.