polymer icon indicating copy to clipboard operation
polymer copied to clipboard

Allow read-only properties to participate in upwards data flow.

Open kaste opened this issue 10 years ago • 6 comments

Yes, that is participate on upwards; restrict like before on downwards.

I think using composition the following element should just work.


    <dom-module id="x-ample">
        <template>
            <x-ajax response="{{data}}" url="[[url]]"></x-ajax>
        </template>
        <script>
            Polymer({
                is: 'x-ample',
                properties: {
                    userId: String,
                    url: {
                        computed: '_computeUrl(userId)',
                        readOnly: true
                    },
                    data: {
                        notify: true,
                        readOnly: true
                    },
                },
                _computeUrl: function(userId) {
                    return '/user/' + userId;
                }
            });
        </script>
    <dom-module>

Current behavior is, that passing url down will work. Yeah, why not, you opted in. But getting the response and let it flow up doesn't. That's completely unnecessary b/c that would be opt-in as well.

Obviously readOnly protects us correctly to not get values from above.

http://jsbin.com/vudovi/edit?html,output

kaste avatar Apr 01 '16 11:04 kaste

Dup of #2632? But this one has the better description/example code.

kaste avatar Apr 10 '16 21:04 kaste

+1

L-u-k-e avatar Apr 14 '16 13:04 L-u-k-e

This change would greatly improve the usecase of writing wrappers around other custom elements. Currently it requires hacks such as computed: '_is(read-only-property)' with _is: function(e) { return e; } to actually make it work.

TimvdLippe avatar Jun 08 '16 09:06 TimvdLippe

This is still a problem in 2.x - can we relabel?

Nipperstick avatar Jun 04 '17 19:06 Nipperstick

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 13 '20 08:03 stale[bot]

This issue has been automatically closed after being marked stale. If you're still facing this problem with the above solution, please comment and we'll reopen!

stale[bot] avatar Apr 16 '22 11:04 stale[bot]