Ignore:
Timestamp:
11/25/21 22:08:24 (3 years ago)
Author:
Ema <ema_spirova@…>
Branches:
master
Children:
8d391a1
Parents:
59329aa
Message:

primeNG components

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trip-planner-front/node_modules/critters/src/index.js

    r59329aa re29cc2e  
    3030/**
    3131 * The mechanism to use for lazy-loading stylesheets.
     32 *
    3233 * Note: <kbd>JS</kbd> indicates a strategy requiring JavaScript (falls back to `<noscript>` unless disabled).
    3334 *
     
    242243        .replace(/^\//, '');
    243244    }
     245
     246    // Ignore remote stylesheets
     247    if (/^https:\/\//.test(normalizedPath) || href.startsWith('//')) {
     248      return undefined;
     249    }
     250
    244251    const filename = path.resolve(outputPath, normalizedPath);
    245252
     
    484491            }
    485492          });
     493
    486494          // If there are no matched selectors, remove the rule:
    487           if (rule.selectors.length === 0) {
     495          if (!rule.selector) {
    488496            return false;
    489497          }
    490498
    491           if (rule.declarations) {
    492             for (let i = 0; i < rule.declarations.length; i++) {
    493               const decl = rule.declarations[i];
     499          if (rule.nodes) {
     500            for (let i = 0; i < rule.nodes.length; i++) {
     501              const decl = rule.nodes[i];
    494502
    495503              // detect used fonts
    496               if (decl.property && decl.property.match(/\bfont(-family)?\b/i)) {
     504              if (decl.prop && decl.prop.match(/\bfont(-family)?\b/i)) {
    497505                criticalFonts += ' ' + decl.value;
    498506              }
    499507
    500508              // detect used keyframes
    501               if (
    502                 decl.property === 'animation' ||
    503                 decl.property === 'animation-name'
    504               ) {
     509              if (decl.prop === 'animation' || decl.prop === 'animation-name') {
    505510                // @todo: parse animation declarations and extract only the name. for now we'll do a lazy match.
    506511                const names = decl.value.split(/\s+/);
     
    515520
    516521        // keep font rules, they're handled in the second pass:
    517         if (rule.type === 'font-face') return;
     522        if (rule.type === 'atrule' && rule.name === 'font-face') return;
    518523
    519524        // If there are no remaining rules, remove the whole rule:
    520         const rules = rule.rules && rule.rules.filter((rule) => !rule.$$remove);
     525        const rules = rule.nodes && rule.nodes.filter((rule) => !rule.$$remove);
    521526        return !rules || rules.length !== 0;
    522527      })
     
    547552
    548553      // prune @keyframes rules
    549       if (rule.type === 'keyframes') {
     554      if (rule.type === 'atrule' && rule.name === 'keyframes') {
    550555        if (keyframesMode === 'none') return false;
    551556        if (keyframesMode === 'all') return true;
    552         return criticalKeyframeNames.indexOf(rule.name) !== -1;
     557        return criticalKeyframeNames.indexOf(rule.params) !== -1;
    553558      }
    554559
    555560      // prune @font-face rules
    556       if (rule.type === 'font-face') {
     561      if (rule.type === 'atrule' && rule.name === 'font-face') {
    557562        let family, src;
    558         for (let i = 0; i < rule.declarations.length; i++) {
    559           const decl = rule.declarations[i];
    560           if (decl.property === 'src') {
     563        for (let i = 0; i < rule.nodes.length; i++) {
     564          const decl = rule.nodes[i];
     565          if (decl.prop === 'src') {
    561566            // @todo parse this properly and generate multiple preloads with type="font/woff2" etc
    562567            src = (decl.value.match(/url\s*\(\s*(['"]?)(.+?)\1\s*\)/) || [])[2];
    563           } else if (decl.property === 'font-family') {
     568          } else if (decl.prop === 'font-family') {
    564569            family = decl.value;
    565570          }
     
    590595    sheet = serializeStylesheet(ast, {
    591596      compress: this.options.compress !== false
    592     }).trim();
     597    });
    593598
    594599    // If all rules were removed, get rid of the style element entirely
Note: See TracChangeset for help on using the changeset viewer.