cristianbote/goober

The behavior of `glob()` was changed in 2.1.11.

iorate opened this issue · 0 comments

In goober <=2.1.10, repetitive calls to glob() append CSS.
In contrast, in 2.1.11, repetitive calls to glob() replace CSS.

<script type="module">
  import { glob } from 'https://esm.sh/goober@2.1.11';

  glob`body { color: red; }`;
  glob`body { font-weight: bold; }`;

  document.body.textContent = window._goober.textContent;

  // 2.1.11
  // body{font-weight:bold;}

  // 2.1.10
  // body{color:red;}body{font-weight:bold;}
</script>

I understand #484 is a necessary change for createGlobalStyles(), but I would like the behavior of glob() to remain the same because I have a hard dependency on it.

Possible update:

// css.js
let glob = css.bind({ g: 1, legacyGlob: 1 });

function css(val) {
  // ...
  return hash(
    // ...
    ctx.legacyGlob
  );
}

// core/hash.js
export let hash = (compiled, sheet, global, append, keyframes, legacyGlob) => {
  // ...
  let cssToReplace = global && !legacyGlob && cache.g ? cache.g : null;
  // ...
};