Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

utils.browser.esm.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. var isBrowser = "object" !== '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 current = serialized;
  29. do {
  30. var maybeStyles = cache.insert("." + className, current, cache.sheet, true);
  31. current = current.next;
  32. } while (current !== undefined);
  33. }
  34. };
  35. export { getRegisteredStyles, insertStyles };