How to use the css-tree.property function in css-tree

To help you get started, we’ve selected a few css-tree 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 css / csso / lib / normalize / Declaration.js View on Github external
module.exports = function Declaration(node) {
    // ignore custom properties (variables) since its names are case sensitive
    if (resolve(node.property).custom) {
        return;
    }

    // .a { PROPERTY: value }
    // ->
    // .a { property: value }
    node.property = node.property.toLowerCase();
};
github peterbe / minimalcss / src / run.js View on Github external
enter: declaration => {
            if (csstree.property(declaration.property).name === 'font-family') {
              const name = utils.unquoteString(
                csstree.generate(declaration.value)
              );
              // was this @font-face used?
              if (!activeFontFamilyNames.has(name)) {
                atruleList.remove(atruleItem);
              }
            }
          }
        });
github pocketjoso / penthouse / src / postformatting / unused-fontface-remover.js View on Github external
enter: declaration => {
          const name = csstree.property(declaration.property).name

          if (name === 'font-family') {
            const familyName = decodeFontName(declaration.value)

            // was this @font-face used?
            if (!fontNameValues.has(familyName)) {
              debuglog('drop unused @font-face: ' + familyName)
              used = false
            }
          } else if (name === 'src') {
            hasSrc = true
          }
        }
      })
github css / csso / lib / replace / Value.js View on Github external
module.exports = function compressValue(node) {
    if (!this.declaration) {
        return;
    }

    var property = resolveName(this.declaration.property);

    if (handlers.hasOwnProperty(property.basename)) {
        handlers[property.basename](node);
    }
};
github css / csso / lib / restructure / 6-restructBlock.js View on Github external
function needless(props, declaration, fingerprints) {
    var property = resolveProperty(declaration.property);

    if (NEEDLESS_TABLE.hasOwnProperty(property.basename)) {
        var table = NEEDLESS_TABLE[property.basename];

        for (var i = 0; i < table.length; i++) {
            var ppre = getPropertyFingerprint(property.prefix + table[i], declaration, fingerprints);
            var prev = props.hasOwnProperty(ppre) ? props[ppre] : null;

            if (prev && (!declaration.important || prev.item.data.important)) {
                return prev;
            }
        }
    }
}
github css / csso / lib / restructure / 6-restructBlock.js View on Github external
function getPropertyFingerprint(propertyName, declaration, fingerprints) {
    var realName = resolveProperty(propertyName).basename;

    if (realName === 'background') {
        return propertyName + ':' + generate(declaration.value);
    }

    var declarationId = declaration.id;
    var fingerprint = fingerprints[declarationId];

    if (!fingerprint) {
        switch (declaration.value.type) {
            case 'Value':
                var vendorId = '';
                var iehack = '';
                var special = {};
                var raw = false;