Sha256: aceb6bda2465b65fac984e291a3fd842f06cb64b13dd261b737c0e3c12634548

Contents?: true

Size: 1.5 KB

Versions: 28

Compression:

Stored size: 1.5 KB

Contents

'use strict';

var baseCssAdapter = require('css-select-base-adapter');

/**
 * DOMUtils API for SVGO AST (used by css-select)
 */
var svgoCssSelectAdapterMin = {

    // is the node a tag?
    // isTag: ( node:Node ) => isTag:Boolean
    isTag: function(node) {
        return node.isElem();
    },

    // get the parent of the node
    // getParent: ( node:Node ) => parentNode:Node
    // returns null when no parent exists
    getParent: function(node) {
        return node.parentNode || null;
    },

    // get the node's children
    // getChildren: ( node:Node ) => children:[Node]
    getChildren: function(node) {
        return node.content || [];
    },

    // get the name of the tag
    // getName: ( elem:ElementNode ) => tagName:String
    getName: function(elemAst) {
        return elemAst.elem;
    },

    // get the text content of the node, and its children if it has any
    // getText: ( node:Node ) => text:String
    // returns empty string when there is no text
    getText: function(node) {
        return node.content[0].text || node.content[0].cdata || '';
    },

    // get the attribute value
    // getAttributeValue: ( elem:ElementNode, name:String ) => value:String
    // returns null when attribute doesn't exist
    getAttributeValue: function(elem, name) {
        return elem.hasAttr(name) ? elem.attr(name).value : null;
    }
};

// use base adapter for default implementation
var svgoCssSelectAdapter = baseCssAdapter(svgoCssSelectAdapterMin);

module.exports = svgoCssSelectAdapter;

Version data entries

28 entries across 27 versions & 9 rubygems

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