How to use the rework.visit function in rework

To help you get started, we’ve selected a few rework examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github postcss / autoprefixer / lib / autoprefixer.js View on Github external
declClone[key] = i[key];
                                }
                                return declClone;
                            });

                        clone.keyframes.push(keyframeClone);
                    });


                    clone.vendor = prefix;
                    style.rules.push(clone);
                });
             });
        }

        rework.visit.declarations(style, function (list, node) {
            var rules = new Rules(list);

            // Properties
            rules.forEach(function (rule) {
                var prop = props[rule.property];

                if ( !prop || !prop.prefixes ) {
                    return;
                }
                if ( prop.check && !prop.check.call(rule.value, rule) ) {
                    return;
                }

                prop.prefixes.forEach(function (prefix) {
                    if ( node.vendor && node.vendor !== prefix ) {
                        return;
github postcss / autoprefixer / lib / autoprefixer.js View on Github external
unprefixer: function (remove, style) {
        var all = remove.values['*'];

        // Keyframes
        style.rules = style.rules.filter(function (rule) {
            return !(rule.keyframes && remove.keyframes[rule.vendor]);
        });

        rework.visit.declarations(style, function (list) {
            var rules = new Rules(list);

            rules.forEach(function (rule) {
                // Properties
                if ( remove.props[rule.property] ) {
                    rules.removeCurrent();
                    return;
                }

                // Values
                var prop   = splitPrefix(rule.property).name;
                var values = all;
                if ( remove.values[prop] ) {
                    values = values.concat(remove.values[prop]);
                }
                if ( prop === 'transition' || prop === 'transition-property' ) {