preload: use page_params only when it exists.

This PR adds a params-util.js file which checks wheather the
page_params exists or not.

Fixes: #517.
This commit is contained in:
aashish-ak
2018-07-20 14:24:02 +05:30
committed by Akash Nimare
parent 124a842bbd
commit 60d10d88d1
3 changed files with 51 additions and 37 deletions

View File

@@ -0,0 +1,15 @@
// This util function returns the page params if they're present else returns null
function isPageParams() {
let webpageParams = null;
try {
// eslint-disable-next-line no-undef, camelcase
webpageParams = page_params;
} catch (err) {
webpageParams = null;
}
return webpageParams;
}
module.exports = {
isPageParams
};