hannahhoward / a1atscript

The Angular 2 Polyfill
MIT License
101 stars 7 forks source link

Angular 1.4.1 trying to access non-existing getters for hidden properties and getting undefined #10

Closed timkindberg closed 9 years ago

timkindberg commented 9 years ago

To reproduce:

import {AsModule, Component, View} from 'a1atscript';

@Component({
  selector: "parent",
  properties: {
    data: 'data'
  }
})
@View({
  inline: `
    <div>This data won't show: {{ parent.data | json }}</div>
    <child bind-data="parent.data"></child>
`
})
export default class ParentComponent { }

@Component({
  selector: "child",
  properties: {
    data: 'data'
  }
})
@View({
  inline: `<div>This data will show: {{ child.data | json }}</div>`
})
export default class ChildComponent { }

@Component({
  selector: "app"
})
@View({
  inline: `<parent bind-data="app.data"></parent>`
})
export default class App { 
    constructor() {
        this.data = {foo: 'bar'}
    }
}

In this scenario, with data cascading from the top-level all the way through two nested components, we are seeing an issue where the data is not shown in the intermediate levels, parent. We've tracked this to a piece of angular.js code that is trying to access the value of our hidden properties—"_@prop" and "=_prop". However, there are now getters set up for those properties so they are returning undefined and forcing a codepath that believes the data needs to be inherited from the scope chain.

Adding getters should fix this.