Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot assign to read only property 'attrDef' of [object Object] #259

Closed
kenvunz opened this issue May 12, 2014 · 5 comments
Labels

Comments

@kenvunz
Copy link

kenvunz commented May 12, 2014

Hi,

Not sure if it's a bug or a feature but if I use the new attributes method to define component and mixin default attributes, an error is thrown but only when the Debug mode is turned on.

Uncaught TypeError: Cannot assign to read only property 'attrDef' of [object Object]

Example

// with-mixin.js

define([], function() {
    'use strict';

    return (function() {
        this.attributes({
            foo: 'baz1'
        });

        this.after('initialize', function() {
            console.log(this.attr);
        });
    });
});

// component.js

define(['flight/lib/component', 'with-mixin'], function(component, withMixin) {
    'use strict';

    return component(function() {

        this.attributes({
            foo: 'baz'
        });

        this.after('initialize', function() {
            console.log(this.attr);
            this.on(document, 'click', function(event) {
                console.log(event);
            });
        });
    }, withMixin);
});

Full error stack

Uncaught TypeError: Cannot assign to read only property 'attrDef' of [object Object] base.js:256
attributes base.js:256
(anonymous function) with-mixin.js:5
mixin compose.js:34
define component.js:123
(anonymous function) component.js:4
context.execCb require.js:1650
Module.check require.js:866
(anonymous function) require.js:1113
(anonymous function) require.js:132
(anonymous function) require.js:1156
each require.js:57
Module.emit require.js:1155
Module.check require.js:917
(anonymous function) require.js:1113
(anonymous function) require.js:132
(anonymous function) require.js:1156
each require.js:57
Module.emit require.js:1155
Module.check require.js:917
Module.enable require.js:1143
Module.init require.js:774
callGetModule require.js:1170
context.completeLoad require.js:1544
context.onScriptLoad

Any clarifications, pointers of how to avoid this error during Debug mode would be great

Cheers
Ken

@necolas
Copy link
Contributor

necolas commented Jun 25, 2014

Is this still an issue in the stable release (1.2.0) that includes this.attributes?

@necolas necolas added the bug label Jun 25, 2014
@prashaantt
Copy link
Contributor

Yes it is. I just ran into this issue too.

Attempting to define this.attributes on a component that also has a mixin that defines its own this.attributes throws this error — and it doesn't matter if the attrs defined are completely different. Reverting to using this.defaultAttrs for both resolves this issue.

@angus-c
Copy link
Contributor

angus-c commented Jun 29, 2014

looks like we need to whitelist attrDef when write protecting. cc @danwrong

@angus-c
Copy link
Contributor

angus-c commented Jun 29, 2014

fixed in branch: attributes_in_debug.
However looking at test failure in master before I PR

@angus-c
Copy link
Contributor

angus-c commented Jun 29, 2014

Fixed: #279

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants