nextui-org / tailwind-variants

🦄 Tailwindcss first-class variant API
https://tailwind-variants.org
MIT License
2.42k stars 68 forks source link

extend does not work as expected #104

Closed GuoXiaoyang closed 1 year ago

GuoXiaoyang commented 1 year ago

Extend does not work as expected. I've created a simple example below.

Once "inputBox" is extended, the "slot" is modified and not immutable. It appears that this pull request (PR) is causing this change.

const inputBox = tv({
  slots: {
    base: "flex",
  },
});
console.log("inputBox", inputBox().base()); // flex

const extendedInput = tv({
  extend: inputBox,
  slots: {
    base: "flex1",
  },
});

// expected: flex flex1, actual: flex flex1
console.log("extendedInput", extendedInput().base()); 
// expected: flex, actual: flex flex1
console.log("inputBox", inputBox().base());

I'm curious as to why the implementation of "joinObjects" was changed to a version with side effects.