.. / jscolor
Star Fork

jscolor is a vanilla JavaScript color picker that turns ordinary form controls into customizable widgets.

jscolor
EastDesire
...

Latest

<any> @data-* 🛡️ unsafe-eval ⏱️ before-load
More information

Sink

Source: https://jscolor.com/release/2.5/jscolor-2.5.2/jscolor.js

var dataOptions = jsc.getDataAttr(targetElm, 'jscolor');
if (dataOptions !== null) {
    optsStr = dataOptions;
} else if (m[4]) {
    optsStr = m[4];
}

var opts = {};
if (optsStr) {
    try {
        opts = (new Function('return (' + optsStr + ')'))();
    } catch(eParseError) {
        jsc.warn('Error parsing jscolor options: ' + eParseError + ':\n' + optsStr);
    }
}

The library automatically calls jsc.pub.install() once DOMContentLoaded fires, which in turn runs installBySelector('[data-jscolor]'). Because the same function can be invoked again later, any element appended after load will hit the exact sink.

// Installs jscolor on current DOM tree
jsc.pub.install = function (rootNode) {
    var success = true;

    try {
        jsc.installBySelector('[data-jscolor]', rootNode);
    } catch (e) {
        success = false;
        console.warn(e);
    }
    // ...
};

Related links:

Found by @ixSly, ixSly.


Source | History