Sha256: 0a5b15612be1365a755b64278b0e103d97ffeadb0e7aa36d0b54420166417ebd

Contents?: true

Size: 1.1 KB

Versions: 34

Compression:

Stored size: 1.1 KB

Contents

'use strict';

exports.type = 'perItem';

exports.active = true;

exports.description = 'removes empty <text> elements';

exports.params = {
    text: true,
    tspan: true,
    tref: true
};

/**
 * Remove empty Text elements.
 *
 * @see http://www.w3.org/TR/SVG/text.html
 *
 * @example
 * Remove empty text element:
 * <text/>
 *
 * Remove empty tspan element:
 * <tspan/>
 *
 * Remove tref with empty xlink:href attribute:
 * <tref xlink:href=""/>
 *
 * @param {Object} item current iteration item
 * @param {Object} params plugin params
 * @return {Boolean} if false, item will be filtered out
 *
 * @author Kir Belevich
 */
exports.fn = function(item, params) {

    // Remove empty text element
    if (
        params.text &&
        item.isElem('text') &&
        item.isEmpty()
    ) return false;

    // Remove empty tspan element
    if (
        params.tspan &&
        item.isElem('tspan') &&
        item.isEmpty()
    ) return false;

    // Remove tref with empty xlink:href attribute
    if (
        params.tref &&
        item.isElem('tref') &&
        !item.hasAttrLocal('href')
    ) return false;

};

Version data entries

34 entries across 31 versions & 11 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/svgo/plugins/removeEmptyText.js
disco_app-0.18.0 test/dummy/node_modules/svgo/plugins/removeEmptyText.js
disco_app-0.18.2 test/dummy/node_modules/svgo/plugins/removeEmptyText.js
disco_app-0.16.1 test/dummy/node_modules/svgo/plugins/removeEmptyText.js
disco_app-0.15.2 test/dummy/node_modules/svgo/plugins/removeEmptyText.js
disco_app-0.18.4 test/dummy/node_modules/svgo/plugins/removeEmptyText.js
disco_app-0.18.1 test/dummy/node_modules/svgo/plugins/removeEmptyText.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/svgo/plugins/removeEmptyText.js
disco_app-0.14.0 test/dummy/node_modules/svgo/plugins/removeEmptyText.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/svgo/plugins/removeEmptyText.js
tang-0.2.1 spec/tang_app/node_modules/svgo/plugins/removeEmptyText.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/svgo/plugins/removeEmptyText.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/svgo/plugins/removeEmptyText.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/svgo/plugins/removeEmptyText.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/svgo/plugins/removeEmptyText.js
tang-0.2.0 spec/tang_app/node_modules/svgo/plugins/removeEmptyText.js
tang-0.1.0 spec/tang_app/node_modules/svgo/plugins/removeEmptyText.js
tang-0.0.9 spec/tang_app/node_modules/svgo/plugins/removeEmptyText.js
enju_library-0.3.8 spec/dummy/node_modules/svgo/plugins/removeEmptyText.js
jester-data-8.0.0 node_modules/svgo/plugins/removeEmptyText.js