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

Exception in notifyPath after Polymer/2007-kschaaf-key-disambiguate #2556

Closed
david-saslawsky opened this issue Oct 10, 2015 · 2 comments
Closed

Comments

@david-saslawsky
Copy link

It seems that there is annotation scoping issue in templates that is now revealed by the changes in 2007-kschaaf-key-disambiguate.

Sorry for the large example, I couldn't make it smaller.

    <dom-module id="x-row">
        <template>
            <p>key=<span>{{model.key}}</span></p>
        </template>
    </dom-module>
    <script>
        Polymer({
            is : 'x-row',

            properties: {
                model: {
                    type: Object
                }
            }
        });
    </script>

    <dom-module id="x-list">
        <template>
            <template is="dom-repeat" items="[[model]]" as="groupData">
                <p>-----</p>
                <template is="dom-repeat" items="[[groupData]]" as="model">
                    <x-row model="[[model]]"></x-row>
                </template>
            </template>
        </template>
    </dom-module>
    <script>
        Polymer({
            is : 'x-list',

            properties: {
                model: {
                    type: Array,
                    value: [
                        [
                            { key:'aaaa' },
                            { key:'bbbb' },
                            { key:'cccc' }
                        ],
                        [
                            { key:'dddd' },
                        ]
                    ]
                }
            }
        });
    </script>

    <x-list id="test"></x-list>
    <input type="button" value="test" onclick="test();">
    <script>
        function test() {
            var test = document.getElementById('test');
            test.set('model.0.1.key', 'dddd');
        }
    </script>

If you click on the test button, there is an exception in the following function from notify-path.html

      _modelForPath: function(path) {
        var dot = path.indexOf('.');    // <--- path is undefined
        return (dot < 0) ? path : path.slice(0, dot);
      },

This is because x-row tag is being notified on the following path: model.#0.#1.key.

If you replace the inner repeat by:

                <template is="dom-repeat" items="[[groupData]]">
                    <x-row model="[[item]]"></x-row>
                </template>

the problem disappears.

This issue had no consequence before the #2007 fix because notifications on invalid paths were simply ignored.

@mgiuffrida
Copy link
Contributor

Chrome is running into this now (TypeErrors in notifyPath calls that did not previously throw an error).

There seems to be some kind of race condition where, if multiple elements reference the same object via data binding, when that object is initially set in one element, a full path for one of that object's sub-sub-sub-properties is sent via notifyPath to another element that hasn't yet received the base object.

If that makes any sense.

@david-saslawsky
Copy link
Author

My first impression is that there is a name collision between the inner template binding [[model]] which is a row and the outer property model which is a list.

I tried to pinpoint the bug around Templatizer._forwardInstanceProp or Base.notifyPath but no luck so far.

sorvell pushed a commit that referenced this issue Oct 29, 2015
Ensure outer paths aren't forwarded to instance props. Fixes #2556.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants