Dashboard sipadu mbip
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

utils.esm.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. var isBrowser = typeof document !== 'undefined';
  2. function getRegisteredStyles(registered, registeredStyles, classNames) {
  3. var rawClassName = '';
  4. classNames.split(' ').forEach(function (className) {
  5. if (registered[className] !== undefined) {
  6. registeredStyles.push(registered[className]);
  7. } else {
  8. rawClassName += className + " ";
  9. }
  10. });
  11. return rawClassName;
  12. }
  13. var insertStyles = function insertStyles(cache, serialized, isStringTag) {
  14. var className = cache.key + "-" + serialized.name;
  15. if ( // we only need to add the styles to the registered cache if the
  16. // class name could be used further down
  17. // the tree but if it's a string tag, we know it won't
  18. // so we don't have to add it to registered cache.
  19. // this improves memory usage since we can avoid storing the whole style string
  20. (isStringTag === false || // we need to always store it if we're in compat mode and
  21. // in node since emotion-server relies on whether a style is in
  22. // the registered cache to know whether a style is global or not
  23. // also, note that this check will be dead code eliminated in the browser
  24. isBrowser === false && cache.compat !== undefined) && cache.registered[className] === undefined) {
  25. cache.registered[className] = serialized.styles;
  26. }
  27. if (cache.inserted[serialized.name] === undefined) {
  28. var stylesForSSR = '';
  29. var current = serialized;
  30. do {
  31. var maybeStyles = cache.insert("." + className, current, cache.sheet, true);
  32. if (!isBrowser && maybeStyles !== undefined) {
  33. stylesForSSR += maybeStyles;
  34. }
  35. current = current.next;
  36. } while (current !== undefined);
  37. if (!isBrowser && stylesForSSR.length !== 0) {
  38. return stylesForSSR;
  39. }
  40. }
  41. };
  42. export { getRegisteredStyles, insertStyles };