Blame view

天文台pc/tianwentai-ui/node_modules/@emotion/utils/dist/emotion-utils.browser.cjs.js 1.86 KB
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  'use strict';
  
  Object.defineProperty(exports, '__esModule', { value: true });
  
  var isBrowser = true;
  
  function getRegisteredStyles(registered, registeredStyles, classNames) {
    var rawClassName = '';
    classNames.split(' ').forEach(function (className) {
      if (registered[className] !== undefined) {
        registeredStyles.push(registered[className] + ";");
      } else if (className) {
        rawClassName += className + " ";
      }
    });
    return rawClassName;
  }
  var registerStyles = function registerStyles(cache, serialized, isStringTag) {
    var className = cache.key + "-" + serialized.name;
  
    if ( // we only need to add the styles to the registered cache if the
    // class name could be used further down
    // the tree but if it's a string tag, we know it won't
    // so we don't have to add it to registered cache.
    // this improves memory usage since we can avoid storing the whole style string
    (isStringTag === false || // we need to always store it if we're in compat mode and
    // in node since emotion-server relies on whether a style is in
    // the registered cache to know whether a style is global or not
    // also, note that this check will be dead code eliminated in the browser
    isBrowser === false ) && cache.registered[className] === undefined) {
      cache.registered[className] = serialized.styles;
    }
  };
  var insertStyles = function insertStyles(cache, serialized, isStringTag) {
    registerStyles(cache, serialized, isStringTag);
    var className = cache.key + "-" + serialized.name;
  
    if (cache.inserted[serialized.name] === undefined) {
      var current = serialized;
  
      do {
        cache.insert(serialized === current ? "." + className : '', current, cache.sheet, true);
  
        current = current.next;
      } while (current !== undefined);
    }
  };
  
  exports.getRegisteredStyles = getRegisteredStyles;
  exports.insertStyles = insertStyles;
  exports.registerStyles = registerStyles;