Files
polymer/test/unit/bind-elements.html

128 lines
3.3 KiB
HTML
Raw Normal View History

<template>
2015-02-09 18:13:58 -08:00
<div id="boundChild" value="{{value}}" negvalue="{{!bool}}" attrvalue$="{{attrvalue}}" computedvalue="{{computedvalue}}" camel-case="{{value}}"></div>
</template>
<script>
Polymer({
is: 'x-basic',
propertyConfig: {
value: {
observer: 'valueChanged'
},
computedvalue: {
computed: 'computeValue(value)',
observer: 'computedvalueChanged'
},
notifyingvalue: {
type: Number,
notify: true,
computed: 'notifyingvalueChanged'
},
computednotifyingvalue: {
type: Number,
notify: true,
computed: 'computeNotifyingValue(notifyingvalue)'
2015-01-22 14:19:42 -08:00
},
computedFromMultipleValues: {
type: Number,
notify: true,
computed: 'computeFromMultipleValues(sum1, sum2, divide)',
observer: 'computedFromMultipleValuesChanged'
},
2015-02-09 18:13:58 -08:00
camelNotifyingValue: {
type: Number,
notify: true
},
2015-01-22 14:19:42 -08:00
readonlyvalue: {
type: Number,
readOnly: true,
notify: true,
observer: 'readonlyvalueChanged'
}
},
observers: {
'dep1 dep2 dep3': 'multipleDepChangeHandler'
},
valueChanged: function() {},
computeValue: function(val) {
return val + 1;
},
computedvalueChanged: function() {},
notifyingvalueChanged: function() {},
2015-01-22 14:19:42 -08:00
readonlyvalueChanged: function() {},
computeNotifyingValue: function(val) {
return val + 2;
},
computeFromMultipleValues: function(sum1, sum2, divide) {
return (sum1 + sum2) / divide;
},
computedFromMultipleValuesChanged: function() {},
multipleDepChangeHandler: function() {}
});
</script>
<template>
2015-01-22 14:19:42 -08:00
<x-basic id="basic1"
value="{{boundvalue}}"
notifyingvalue="{{boundnotifyingvalue}}"
2015-02-09 18:13:58 -08:00
camel-notifying-value="{{boundnotifyingvalue}}"
2015-01-22 14:19:42 -08:00
computedvalue="{{boundcomputedvalue}}"
computednotifyingvalue="{{boundcomputednotifyingvalue}}"
readonlyvalue="{{boundreadonlyvalue}}">
</x-basic>
<x-basic id="basic2"
value="[[boundvalue]]"
notifyingvalue="[[boundnotifyingvalue]]"
computedvalue="[[boundcomputedvalue]]"
computednotifyingvalue="[[boundcomputednotifyingvalue]]">
</x-basic>
</template>
<script>
Polymer({
is: 'x-compose',
observers: {
2015-01-22 14:19:42 -08:00
boundvalue: 'boundvalueChanged',
boundnotifyingvalue: 'boundnotifyingvalueChanged',
boundcomputedvalue: 'boundcomputedvalueChanged',
2015-01-22 14:19:42 -08:00
boundcomputednotifyingvalue: 'boundcomputednotifyingvalueChanged',
boundreadonlyvalue: 'boundreadonlyvalueChanged'
},
boundvalueChanged: function() {},
boundnotifyingvalueChanged: function() {},
boundcomputedvalueChanged: function() {},
2015-01-22 14:19:42 -08:00
boundcomputednotifyingvalueChanged: function() {},
boundreadonlyvalueChanged: function() {}
});
</script>
<script>
Polymer({
is: 'x-reflect',
propertyConfig: {
reflectedobject: {
type: Object,
reflect: true
},
reflectedarray: {
type: Array,
reflect: true
},
2015-02-09 18:35:03 -08:00
reflectedNumber: {
type: Number,
reflect: true
},
reflectedstring: {
type: String,
reflect: true
},
reflectedboolean: {
type: Boolean,
reflect: true
},
reflecteddate: {
type: Date,
reflect: true
}
}
});
</script>