hustcc / placeholder.js

:zap: < 1Kb library to generate image placeholders on client side

Home Page:http://placeholder.cn/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please can you use strict mode to write this plugin

drnkwati opened this issue · comments

Using strict mode will prevent run-time errors in most modern JavaScript environment
Please run a build with strict mode enabled
spercifically the errors came from you usage of split

parameters[i].split('=')
this throws errors in console during runtime
thanks

If some idea, give me a pr for help?

I fixed this line and it worked perfectly.
Type check string before attempting to split
You can update the master branch

//从url中解析配置信息
function parseUrlOptions(url) {
var opts = {},
parameters = url.split('&'),
k_v;
//
for (var i in parameters) {
if (typeof parameters[i] == 'string') {
k_v = parameters[i].split('=');
try {
opts[k_v[0]] = decodeURIComponent(k_v[1]);
} catch (e) {
opts[k_v[0]] = k_v[1];
}
}
}

    return opts;
}

I love this library
thanks