Skip to content

Commit

Permalink
feat: add title attribute to Compiled style tag
Browse files Browse the repository at this point in the history
  • Loading branch information
pancaspe87 committed Mar 20, 2024
1 parent 44b1323 commit b2531bf
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-lies-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@compiled/parcel-optimizer': minor
---

Add title attribute to Compiled style tag to discern with other style within the page
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ yarn test <filter> --watch

Looking at tests first is generally the best way to get started.

- Run a specific test file: `yarn test <filename> --watch`
- Run a specific test file: `yarn test <filename> --watch` OR `yarn test:parcel <filename>` if the test file name ends with `parceltest.{ts,tsx}`
- Run tests related to a package `yarn test:packageName --watch`
- Update snapshot tests after implementing a code change: `yarn test <filter> --watch --updateSnapshot`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('optimizer', () => {
'utf8'
);

const css = /<style>(.*?)<\/style>/.exec(outputHtml)?.pop();
const css = /<style title="compiled">(.*?)<\/style>/.exec(outputHtml)?.pop();

if (!css) throw new Error('No CSS is found.');

Expand Down
2 changes: 1 addition & 1 deletion packages/parcel-optimizer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default new Optimizer<ParcelOptimizerOpts, unknown>({
.use(
insertAt({
selector: 'head',
append: '<style>' + stylesheet + '</style>',
append: '<style title="compiled">' + stylesheet + '</style>',
behavior: 'inside',
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ it('transforms assets with compiled and extraction babel plugins', async () => {
'utf8'
);

const css = /<style>(.*?)<\/style>/.exec(outputHtml)?.pop();
const css = /<style title="compiled">(.*?)<\/style>/.exec(outputHtml)?.pop();

if (!css) throw new Error('No CSS is found.');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ it('transforms assets with compiled and extraction babel plugins', async () => {
'utf8'
);

const css = /<style>(.*?)<\/style>/.exec(outputHtml)?.pop();
const css = /<style title="compiled">(.*?)<\/style>/.exec(outputHtml)?.pop();

if (!css) throw new Error('No CSS is found.');

Expand Down Expand Up @@ -310,7 +310,7 @@ it('transforms assets with class name compression enabled', async () => {
'utf8'
);

const css = /<style>(.*?)<\/style>/.exec(outputHtml)?.pop();
const css = /<style title="compiled">(.*?)<\/style>/.exec(outputHtml)?.pop();

if (!css) throw new Error('No CSS is found.');

Expand Down

0 comments on commit b2531bf

Please sign in to comment.