Skip to content

Commit ed97284

Browse files
committed
Merge pull request #28 from GoogleWebComponents/fix-firebase-document-update
Ensure that the document is mutable.
2 parents 098e31c + 19dc8c5 commit ed97284

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

firebase-document.html

+2-3
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@
5656
*/
5757
data: {
5858
type: Object,
59-
notify: true,
60-
readOnly: true
59+
notify: true
6160
}
6261
},
6362

@@ -81,7 +80,7 @@
8180

8281
_onFirebaseValue: function(event) {
8382
this._applyRemoteDataChange(function() {
84-
this._setData(event.detail.val());
83+
this.set('data', event.detail.val());
8584
});
8685
},
8786

test/firebase-document.html

+35
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@
3131
</firebase-document>
3232
</template>
3333
</test-fixture>
34+
<test-fixture id="UpdateableDocument">
35+
<template>
36+
<firebase-document
37+
location="https://fb-element-demo.firebaseio.com/test/updateable_document"
38+
log>
39+
</firebase-document>
40+
</template>
41+
</test-fixture>
3442
<test-fixture id="MalleableDocument">
3543
<template>
3644
<firebase-document
@@ -69,6 +77,33 @@
6977
});
7078
});
7179

80+
suite('document updating', function() {
81+
setup(function(done) {
82+
firebase = fixture('UpdateableDocument');
83+
waitForEvent(firebase, 'firebase-value').then(function() {
84+
done();
85+
});
86+
});
87+
88+
test('setting data property updates the document', function(done) {
89+
var data = {};
90+
var newValue = Math.random().toString().split('.').pop();
91+
92+
data[newValue] = newValue;
93+
94+
waitForEvent(firebase, 'firebase-value').then(function() {
95+
expect(firebase.data[newValue]).to.be.eql(newValue);
96+
done();
97+
}).catch(function(e) {
98+
done(e);
99+
}).then(function() {
100+
firebase.set('data.' + newValue, null);
101+
});
102+
103+
firebase.set('data', data);
104+
});
105+
});
106+
72107
suite('document manipulation', function() {
73108
var localFirebase;
74109
var remoteFirebase;

0 commit comments

Comments
 (0)