now icon indicating copy to clipboard operation
now copied to clipboard

Bug setting a variable on a group

Open scriby opened this issue 12 years ago • 0 comments

Hi,

I'm not sure if you're still maintaining this library or not, but I ran across a bug. If I set a now variable from the server in this way it throws an error:

everyone.now.test = {};
everyone.now.test.testing = {};

The reason I'm trying to do it in this manner is I'm lazy initializing some keys. So first I want to make a bucket if it doesn't exist, then add something to the bucket if it doesn't exist, or update it if it does.

It seems to work ok if when everyone.now.test is initially defined it's not an empty object. So this seems to work:

everyone.now.test = { a: 'b' };
everyone.now.test.testing = {};

Here's the stack trace:

TypeError: Object #<Object> has no method 'indexOf'
    at ScopeTable.deleteVar (.../node_modules/now/lib/scopeTable.js:50:35)
    at deleteVar (.../node_modules/now/lib/handlers.js:126:22)
    at exports.initialize.nowjs.on.self (.../node_modules/now/lib/handlers.js:139:5)
    at EventEmitter.emit (events.js:96:17)
    at exports.initialize.Group.deleteVar (.../node_modules/now/lib/group.js:306:11)
    at replaceVar (.../node_modules/now/lib/handlers.js:77:13)
    at exports.initialize.nowjs.on.self (.../node_modules/now/lib/handlers.js:135:5)
    at EventEmitter.emit (events.js:96:17)
    at exports.initialize.Group.set (.../node_modules/now/lib/group.js:314:11)
    at Object.exports.wrap.Proxy.create.set (.../node_modules/now/lib/proxy.js:48:16)

I still haven't gotten my head around the source, so wondering if you might want to take a look.

scriby avatar Jan 18 '13 02:01 scriby