Skip to content

Commit 2061519

Browse files
author
Dan Lasky
committed
fixes for data binding in sync (doob events were stepping on the polymer binding)
1 parent 4363f82 commit 2061519

3 files changed

Lines changed: 74 additions & 27 deletions

File tree

src/mm-sync/index.html

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</head>
2121
<body>
2222

23-
<dom-module id="test-extend">
23+
<!-- <dom-module id="test-extend">
2424
<template>
2525
<content id="content" select="*"></content>
2626
</template>
@@ -30,11 +30,11 @@
3030
is:"test-extend",
3131
behaviors:[StrandLib.Sync.getBehavior()],
3232
});
33-
</script>
33+
</script> -->
3434

35-
<template is="dom-bind">
35+
<!-- <template is="dom-bind">
3636
<mm-input value="{{autoTest}}"></mm-input><span>{{autoTest}}</span>
37-
<mm-sync endpoint="http://localhost:8000/ajax" debug="true">
37+
<mm-sync endpoint="http://localhost:8000/ajax" debug="true" data="{{toaster}}">
3838
<input-params>
3939
<queryParam name="q" value="ui.*"></queryParam>
4040
<queryParam name="user">userInnerVal</queryParam>
@@ -49,7 +49,53 @@
4949
<header name="x-test">acesInner</header>
5050
</output-params>
5151
</mm-sync>
52-
</template>
52+
<span>{{toaster}}</span>
53+
<span>{{toaster.user}}</span>
54+
<span>{{toaster.q}}</span>
55+
<span>{{toaster.nocache}}</span>
56+
</template> -->
57+
58+
<dom-module id="s-test">
59+
<template>
60+
<mm-input value="{{autoTest}}"></mm-input><span>{{autotest}}</span>
61+
<mm-sync endpoint="http://localhost:8000/ajax" data="{{zippy}}">
62+
<input-params>
63+
<queryParam name="q" value="ui.*"></queryParam>
64+
<queryParam name="user">userInnerVal</queryParam>
65+
<urlParam value="ajax"></urlParam>
66+
<urlParam value="123"></urlParam>
67+
<urlParam>innerVal</urlParam>
68+
<urlParam value="settings"></urlParam>
69+
<queryParam name="z">{{autoTest}}</urlParam>
70+
</input-params>
71+
<output-params>
72+
<urlParam>1234</urlParam>
73+
<header name="x-test">acesInner</header>
74+
</output-params>
75+
</mm-sync>
76+
<span>{{zippy.user}}</span>
77+
<span>{{zippy.q}}</span>
78+
<span>{{zippy.nocache}}</span>
79+
</template>
80+
</dom-module>
81+
82+
<script>
83+
Polymer({
84+
is:'s-test',
85+
properties:{
86+
zippy:{
87+
notify:true,
88+
value:null,
89+
type:Object,
90+
observer:"_test"
91+
}
92+
},
93+
_test: function() {
94+
console.log('toaster',this.toaster);
95+
}
96+
});
97+
</script>
98+
<s-test></s-test>
5399

54100
<!-- <polymer-element name="test-login">
55101
<template>

src/mm-sync/mm-sync.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44
* This code may only be used under the BSD style license found at http://mediamath.github.io/strand/LICENSE.txt
55
66
*/
7-
::content {
8-
display:none;
9-
}
10-
117
:host {
128
display:none;
139
}
14-
15-
:host([debug]) {
16-
display:block;
17-
}

src/shared/js/sync.html

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@
7575
withCredentials:false,
7676
concurrency:4,
7777
}, this.options, options);
78-
this.data = this.data || data || {};
78+
79+
if (this.set) {
80+
this.set('data', this.data || data || {});
81+
} else {
82+
this.data = this.data || data || {};
83+
}
7984

8085
this.domHook = this.domHook || domHook;
8186
this.saveResponse = (typeof saveResponse === "boolean") ? saveResponse : true;
@@ -132,7 +137,12 @@
132137
result = this._plugin.processResponse(result);
133138

134139
if (this.saveResponse) {
135-
this.data = result.marshalled;
140+
// this.data = result.marshalled;
141+
if (this.set) {
142+
this.set('data', result.marshalled);
143+
} else {
144+
this.data = result.marshalled;
145+
}
136146
this.fire("saved", result);
137147
}
138148
},
@@ -175,20 +185,19 @@
175185
},
176186
};
177187

178-
scope.Sync.getBehavior = function() {
179-
var beh = BehaviorUtils.extend({
180-
properties: {
181-
data:{
182-
notify:true
183-
}
184-
},
185-
ready: function() {
186-
scope.Sync.apply(this);
188+
var beh = BehaviorUtils.extend({
189+
properties: {
190+
data:{
191+
notify:true
187192
}
188-
}, scope.Sync.prototype);
189-
190-
delete beh.fire; //not needed since there is support in polymer for this
193+
},
194+
ready: function() {
195+
scope.Sync.apply(this);
196+
}
197+
}, scope.Sync.prototype);
198+
delete beh.fire;
191199

200+
scope.Sync.getBehavior = function() {
192201
return beh;
193202
};
194203

0 commit comments

Comments
 (0)