ngUpgraders / ng-forward

The default solution for those that want to write Angular 2.x style code in Angular 1.x
411 stars 36 forks source link

in alpha 0.08 suddenly the bindings don't work #82

Closed david-gang closed 8 years ago

david-gang commented 8 years ago

Now in every place where i have <mycomp [attribute-x] = "ctrl.y()"> I get TypeError: Cannot read property of undefined I cannot trace the problem because problems in the source map

This is the full stack error:

angular.js:12477 TypeError: Cannot read property 'x' of undefined at setBindingUsed (http://localhost:8000/a/lib/bundle.js:127126:40) at Y. (http://localhost:8000/a/lib/bundle.js:127118:17) at Function.assign (native) at exports.default (http://localhost:8000/a/lib/bundle.js:127342:12) at new ddo.controller (http://localhost:8000/a/lib/bundle.js:126472:57) at Object.invoke (http://localhost:8000/a/lib/bundle.js:56381:17) at extend.instance (http://localhost:8000/a/lib/bundle.js:61039:34) at nodeLinkFn (http://localhost:8000/a/lib/bundle.js:60151:36) at http://localhost:8000/a/lib/bundle.js:60422:13 at processQueue (http://localhost:8000/a/lib/bundle.js:66648:28)(anonymous function) @ angular.js:12477(anonymous function) @ angular.js:9246processQueue @ angular.js:14753(anonymous function) @ angular.js:14761Scope.$eval @ angular.js:15989Scope.$digest @ angular.js:15800Scope.$apply @ angular.js:16097(anonymous function) @ angular.js:23554eventHandler @ angular.js:3298run @ core.js:96zoneBoundFn @ core.js:69focusElement @ angular-material.js:17037(anonymous function) @ angular-material.js:16973(anonymous function) @ angular-material.js:1156processQueue @ angular-material.js:1155(anonymous function) @ angular.js:17855completeOutstandingRequest @ angular.js:5507(anonymous function) @ angular.js:5784arguments.(anonymous function) @ functions.js:22(anonymous function) @ core.js:76run @ core.js:96zoneBoundFn @ core.js:69 angular.js:12477 TypeError: Cannot read property 'changeFunction' of undefined

This is urgent as i cannot downgrade to alpha7. There it downloads reactive/rxjs 0.10.

so basically i am stuck

MikeRyanDev commented 8 years ago

Seems like it might be related to #81

Did you upgrade to Babel 6 by chance?

david-gang commented 8 years ago

I am not using babel. I am using browserify and tsify with typescript

david-gang commented 8 years ago

I get the exception at lib/util/directive-controller.ts at line 28.

Object.assign(instance, caller);

Would it interest you to get the values of instance and caller. Are there any additional details i can provide?

david-gang commented 8 years ago

the good news are that it works with alpha7 and a little tweak in npm-shrinkwrap to download the correct version of rx. This means that the regression happened at a later commit

timkindberg commented 8 years ago

I don't understand. @david-gang is this a problem with our codebase or one of our dependencies?

david-gang commented 8 years ago

Hi @timkindberg, It is not a problem with one of my dependencies. Rather in alpha 7 the dependencies were not well defined.

david-gang commented 8 years ago

this is not connected to #81 I built now from master after 82 was closed and experienced the same problem

david-gang commented 8 years ago

Now that we have source maps via #99 I see more :-)

The function fails here:

in inputs-builder.js

 function createHiddenPropSetter(BIND_TYPE, __privateKey) {
        return function (val) {
            this[__privateKey] = val;
            if (isDefined(val)) {
                setBindingUsed(BIND_TYPE, localKey);
            }
            if (controller[__using_binding][localKey] === BIND_TYPE) {
                this[localKey] = val;
            }
        };
    }

controller[__using_binding] is undefined.

Now we have just to understand why

eXaminator commented 8 years ago

I have the same problem.

It seems that these lines do not create the expected object on the controller, thus it is not defined further down the line. Sadly I also don't have any idea how you could fix that right now.

brandonroberts commented 8 years ago

@david-gang @eXaminator I'm gonna blame it on the Symbol() in https://github.com/ngUpgraders/ng-forward/blob/master/lib/properties/inputs-builder.ts#L33-L36.

Change those to strings and see if that helps.

  let __stringKey = '__stringKey';
  let __oneWayKey = '__oneWayKey';
  let __twoWayKey = '__twoWayKey';
  let __using_binding = '__using_binding';
eXaminator commented 8 years ago

I just did that myself (only for __using_binding) and it worked...

timkindberg commented 8 years ago

ugh... I really want to use Symbols... so when you inspect/debug in dev tools you don't see a million auto-generated properties/getters/setters on your class instance objects.

I may have time to look at this tonight to see if there is a way to keep the Symbols.

timkindberg commented 8 years ago

I'm trying to work on this right now... if anyone can hop on gitter and help me recreate the bug?

timkindberg commented 8 years ago

Can someone please create a plunkr that reproduces this bug? I'm not getting it.

http://plnkr.co/edit/ktxXKHyHQ5DLcixe6kpO?p=preview

eXaminator commented 8 years ago

I'll have a look at this tonight and see if I can create a broken plunker somehow.

david-gang commented 8 years ago

Hi,

I think i have the error. We have just to add zone.js to the plunkr.

Thanks, DAvid

david-gang commented 8 years ago

http://plnkr.co/edit/B1XmxWwDadT5OslB7SeX?p=preview

eXaminator commented 8 years ago

I can confirm this. I removed zone.js from my project and everything works.

timkindberg commented 8 years ago

So zone doesn't like symbols?

david-gang commented 8 years ago

Closing :-)