Skip to content

Commit

Permalink
fix: plugin loading resets variants #330 (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
otonashixav committed Jul 12, 2021
1 parent 33495a8 commit db1facc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ export class Processor {
}
this._config = this._resolveFunction(this._config);
this._theme = this._config.theme;
this._variants = this.resolveVariants();
this._variants = { ...this._variants, ...this.resolveVariants() };
handler(this.pluginUtils);
}

Expand Down
5 changes: 5 additions & 0 deletions test/interface/__snapshots__/plugin.test.ts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ Tools / addComponents with attribute selectors / css / 0: |-
--tw-text-opacity: 0.2;
color: hsla(var(--bc,215 28% 17%)/var(--tw-text-opacity));
}
Tools / variants not cleared when plugin loaded / css / 0: |-
.variant .variant\:text-black {
--tw-text-opacity: 1;
color: rgba(0, 0, 0, var(--tw-text-opacity));
}
17 changes: 17 additions & 0 deletions test/interface/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,21 @@ describe('plugin interface test', () => {

expect(processor.preflight(' ', false, false, true).build()).toMatchSnapshot('css');
});

it('variants not cleared when plugin loaded', () => {
const processor = new Processor({
plugins: [
{
handler: ({ addVariant }) => {
addVariant('variant', ({ parent }) => parent('.variant'));
},
},
{
handler: () => {/* Nothing */},
},
],
});

expect(processor.interpret('variant:text-black').styleSheet.build()).toMatchSnapshot('css');
});
});

0 comments on commit db1facc

Please sign in to comment.