diff --git a/src/parse-srcset.js b/src/parse-srcset.js index 9920871..9281be5 100644 --- a/src/parse-srcset.js +++ b/src/parse-srcset.js @@ -30,7 +30,9 @@ }(this, function () { // 1. Let input be the value passed to this algorithm. - return function (input) { + return function (input, onError) { + + onError = onError || (typeof console !== "undefined" && console.log); // UTILITY FUNCTIONS @@ -320,8 +322,8 @@ if (d) { candidate.d = d;} if (h) { candidate.h = h;} candidates.push(candidate); - } else if (console && console.log) { - console.log("Invalid srcset descriptor found in '" + + } else if (onError) { + onError("Invalid srcset descriptor found in '" + input + "' at '" + desc + "'."); } } // (close parseDescriptors fn)