Skip to content

Commit 23b2326

Browse files
committed
ensured plain-object
1 parent b66db7b commit 23b2326

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

dist/breinify-api.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -14959,7 +14959,7 @@ dependencyScope.jQuery = $;;
1495914959

1496014960
init: function (entries, callback) {
1496114961
if (!$.isPlainObject(entries)) {
14962-
return;
14962+
entries = {};
1496314963
}
1496414964

1496514965
// check if we already have an instance (init may be called multiple times)
@@ -15075,8 +15075,11 @@ dependencyScope.jQuery = $;;
1507515075
},
1507615076

1507715077
isExpired: function (name) {
15078-
let json = this.instance.getItem('breinify-' + name);
15078+
if (this.instance === null || !$.isFunction(this.instance.getItem)) {
15079+
return true;
15080+
}
1507915081

15082+
let json = this.instance.getItem('breinify-' + name);
1508015083
if (typeof json === 'string') {
1508115084
let storableData = JSON.parse(json);
1508215085
if ($.isPlainObject(storableData)) {
@@ -15090,6 +15093,10 @@ dependencyScope.jQuery = $;;
1509015093
},
1509115094

1509215095
update: function (name, expiresInSec, data) {
15096+
if (this.instance === null || !$.isFunction(this.instance.setItem)) {
15097+
return;
15098+
}
15099+
1509315100
this.instance.setItem('breinify-' + name, this.createStorableData(expiresInSec, data));
1509415101
},
1509515102

@@ -15110,6 +15117,10 @@ dependencyScope.jQuery = $;;
1511015117
},
1511115118

1511215119
get: function (name) {
15120+
if (this.instance === null || !$.isFunction(this.instance.getItem)) {
15121+
return null;
15122+
}
15123+
1511315124
let json = this.instance.getItem('breinify-' + name);
1511415125
if (typeof json === 'string') {
1511515126
let storableData = JSON.parse(json);

dist/breinify-api.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/BreinifyUtil.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -1841,7 +1841,7 @@
18411841

18421842
init: function (entries, callback) {
18431843
if (!$.isPlainObject(entries)) {
1844-
return;
1844+
entries = {};
18451845
}
18461846

18471847
// check if we already have an instance (init may be called multiple times)
@@ -1957,8 +1957,11 @@
19571957
},
19581958

19591959
isExpired: function (name) {
1960-
let json = this.instance.getItem('breinify-' + name);
1960+
if (this.instance === null || !$.isFunction(this.instance.getItem)) {
1961+
return true;
1962+
}
19611963

1964+
let json = this.instance.getItem('breinify-' + name);
19621965
if (typeof json === 'string') {
19631966
let storableData = JSON.parse(json);
19641967
if ($.isPlainObject(storableData)) {
@@ -1972,6 +1975,10 @@
19721975
},
19731976

19741977
update: function (name, expiresInSec, data) {
1978+
if (this.instance === null || !$.isFunction(this.instance.setItem)) {
1979+
return;
1980+
}
1981+
19751982
this.instance.setItem('breinify-' + name, this.createStorableData(expiresInSec, data));
19761983
},
19771984

@@ -1992,6 +1999,10 @@
19921999
},
19932000

19942001
get: function (name) {
2002+
if (this.instance === null || !$.isFunction(this.instance.getItem)) {
2003+
return null;
2004+
}
2005+
19952006
let json = this.instance.getItem('breinify-' + name);
19962007
if (typeof json === 'string') {
19972008
let storableData = JSON.parse(json);

0 commit comments

Comments
 (0)