Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix misordered CSS resources (#48244)
### What? This PR fixes misordered CSS `<link>` tags. CSS imports in inner layers (e.g. a page) should always take precedence over outer layers (e.g. root layout), but currently it's reversed. ### Why? In layouts we usually define more general styles like globals, resets, and layout specific things. And in inner layers and pages, things need to be more detailed and override upper layers if there're any conflicts. Previously we defined the component segment as ```tsx <> <Component {...props} /> {assets} </> ``` which is necessary because of `findDOMNode` - if we put `assets` before the component, we can't find the correct scrolling DOM and position for that layer. However, with `assets` being the last Float will receive the reversed order of resources. ### How? I changed the `createComponentTree` function to return a `Component` and `assets` pair, so in the Layout Router they're no longer passed to the scroll wrapper altogether but separately. Closes NEXT-983 Fixes #47585, fixes #46347. fix NEXT-656 --------- Co-authored-by: JJ Kasper <jj@jjsweb.site>
- Loading branch information
Showing
8 changed files
with
165 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@layer default; | ||
|
||
@layer default { | ||
h1 { | ||
color: black; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@layer default { | ||
input[type='text'] { | ||
padding: 0.5rem; | ||
} | ||
|
||
h1 { | ||
color: red; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use client' | ||
|
||
import './input.css' | ||
|
||
export default function InputText() { | ||
return <input /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import './index.css' | ||
|
||
export default function Layout({ children }) { | ||
return <div>{children}</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import InputText from './input' | ||
|
||
export default function Home() { | ||
return ( | ||
<div> | ||
<h1>Hello</h1> | ||
<InputText /> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.