Sha256: a4f7a51d37acb2a1133e4a951f1be5cdab412f3e3bc235802190014485629676

Contents?: true

Size: 1.15 KB

Versions: 6

Compression:

Stored size: 1.15 KB

Contents

'use strict';

var parseMeasurement = require('../parsers').parseMeasurement;

/*jslint regexp: true*/
var shape_regex = /^rect\((.*)\)$/i;
/*jslint regexp: false*/

var parse = function (val) {
    if (val === '' || val === null) {
        return val;
    }
    if (typeof val !== 'string') {
        return undefined;
    }
    val = val.toLowerCase();
    if (val === 'auto' || val === 'inherit') {
        return val;
    }
    var matches = val.match(shape_regex);
    if (!matches) {
        return undefined;
    }
    var parts = matches[1].split(/\s*,\s*/);
    if (parts.length !== 4) {
        return undefined;
    }
    var valid = parts.every(function (part, index) {
        var measurement = parseMeasurement(part);
        parts[index] = measurement;
        return measurement !== undefined;
    });
    if (!valid) {
        return undefined;
    }
    parts = parts.join(', ');
    return val.replace(matches[1], parts);
};

module.exports.definition = {
    set: function (v) {
        this._setProperty('clip', parse(v));
    },
    get: function () {
        return this.getPropertyValue('clip');
    },
    enumerable: true,
    configurable: true
};

Version data entries

6 entries across 5 versions & 4 rubygems

Version Path
learn_create-0.0.22 lib/templates/javascript_lab_template/node_modules/cssstyle/lib/properties/clip.js
locomotivecms-4.0.0.alpha1 app/javascript/node_modules/cssstyle/lib/properties/clip.js
locomotivecms-3.4.0 app/javascript/node_modules/cssstyle/lib/properties/clip.js
locomotivecms-3.4.0 app/javascript/node_modules/jest-environment-jsdom/node_modules/cssstyle/lib/properties/clip.js
lanes-0.8.0 node_modules/cssstyle/lib/properties/clip.js
select_all-rails-0.3.1 node_modules/cssstyle/lib/properties/clip.js