Skip to content

Commit 6ad199e

Browse files
fix: allow context object to be null
1 parent e08cd47 commit 6ad199e

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

packages/database/lib/DatabaseQuery.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export default class DatabaseQuery extends ReferenceBase {
218218
throw new Error("firebase.database().ref().off(_, *) 'callback' must be a function.");
219219
}
220220

221-
if (!isUndefined(context) && !isObject(context)) {
221+
if (!isUndefined(context) && !isNull(context) && !isObject(context)) {
222222
throw new Error("firebase.database().ref().off(_, _, *) 'context' must be an object.");
223223
}
224224

@@ -287,7 +287,7 @@ export default class DatabaseQuery extends ReferenceBase {
287287
);
288288
}
289289

290-
if (!isUndefined(context) && !isObject(context)) {
290+
if (!isUndefined(context) && !isNull(context) && !isObject(context)) {
291291
throw new Error("firebase.database().ref().on(_, _, _, *) 'context' must be an object.");
292292
}
293293

packages/database/lib/modular/query.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ function addEventListener(query, eventType, callback, cancelCallbackOrListenOpti
145145
};
146146
}
147147

148-
query.on.call(query, eventType, callback, cancelCallback, MODULAR_DEPRECATION_ARG);
148+
query.on.call(query, eventType, callback, cancelCallback, null, MODULAR_DEPRECATION_ARG);
149149

150-
return () => query.off.call(query, eventType, callback, MODULAR_DEPRECATION_ARG);
150+
return () => query.off.call(query, eventType, callback, null, MODULAR_DEPRECATION_ARG);
151151
}
152152

153153
/**
@@ -211,8 +211,7 @@ export function onChildRemoved(query, callback, cancelCallbackOrListenOptions, o
211211
* @returns {Promise<void>}
212212
*/
213213
export function set(ref, value) {
214-
//return ref.set.call(ref, value, () => {}, MODULAR_DEPRECATION_ARG);
215-
return ref.set.call(ref, value, MODULAR_DEPRECATION_ARG);
214+
return ref.set.call(ref, value, () => {}, MODULAR_DEPRECATION_ARG);
216215
}
217216

218217
/**
@@ -239,7 +238,14 @@ export function setWithPriority(ref, value, priority) {
239238
* @returns {DataSnapshot}
240239
*/
241240
export function get(query) {
242-
return query.once.call(query, 'value', () => {}, () => {}, {}, MODULAR_DEPRECATION_ARG);
241+
return query.once.call(
242+
query,
243+
'value',
244+
() => {},
245+
() => {},
246+
{},
247+
MODULAR_DEPRECATION_ARG,
248+
);
243249
}
244250

245251
export function off(_query, _eventType, _callback) {

0 commit comments

Comments
 (0)