mirror of
https://github.com/twitter/twemoji.git
synced 2024-06-15 03:35:16 +00:00
Validate the first argument of parse method
The first argument type of `parse` method can only be of `String` or `HTML Element`.
This commit is contained in:
parent
2c4d66ec91
commit
ad1fc0e48d
10
2/twemoji.js
10
2/twemoji.js
@ -515,6 +515,14 @@ var twemoji = (function (
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parse(what, how) {
|
function parse(what, how) {
|
||||||
|
// first argument can only be string or HTML Element
|
||||||
|
if (
|
||||||
|
typeof what !== 'string' &&
|
||||||
|
!(what && what.nodeName)
|
||||||
|
) {
|
||||||
|
return what;
|
||||||
|
}
|
||||||
|
|
||||||
if (!how || typeof how === 'function') {
|
if (!how || typeof how === 'function') {
|
||||||
how = {callback: how};
|
how = {callback: how};
|
||||||
}
|
}
|
||||||
@ -563,4 +571,4 @@ var twemoji = (function (
|
|||||||
return r.join(sep || '-');
|
return r.join(sep || '-');
|
||||||
}
|
}
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
Loading…
Reference in New Issue
Block a user