"setting a property that only has a getter" - javascript error with firefox

Until recently, I used Safari 4 to test and debug my current jQuery plugin. I tried my code in Firefox and he started complaining about something in the JQuery-Framework: "setting a property that only has a getter." I tried to figure out which line makes Firefox complain and found that this is happening somewhere here **

$.fn.util.create_$dom = function(opt) {
    var $dom = {};
    $.each(opt.dom,function(name,val){
        console.log(name);
        var $elm = $('<div>');
        $.each(opt.dom[name],function(_name,_val){
            if(_name == 'tagName') $elm = $('<'+_val+'/>');
        });
                    console.log(name+': ok');
        $.each(opt.dom[name],function(_name,_val){             **here       
            switch(_name){                                     **here
                case 'className': $elm.addClass(_val);         **here
                default: $elm.attr(_name, _val);               **here
            }                                                  **here
        });
        $dom[name] = $elm;
        console.log(name+': ok');
    });
    return $dom;
};

options.dom looks like this:

    dom:{
        wrapper:{className:'wrapper'},
        inner:{tagName:'p',className:'test',test:'bla'}
    },
+5
source share
2 answers

It looks like you are trying to set the tagName of an element with this string

$elm.attr(_name, _val); 

This, of course, is not possible because it is read-only.

+7
case 'tagName': break;

... , , redsquare , .

+3

All Articles