-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(next/image): render valid html according to W3C #33825
Merged
styfle
merged 11 commits into
vercel:canary
from
theoludwig:fix/next-image-render-valid-html-w3c
Feb 1, 2022
Merged
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e4151df
test(next/image): render valid HTML according to W3C
theoludwig 2fe8dac
fix(next/image): render valid HTML according to W3C
theoludwig 0effe96
build(deps): bump html-validator from v6 to v5
theoludwig 1aa3e6e
refactor: move valid-html-w3c test to default
theoludwig f9967df
test: typo
theoludwig d0303d7
Revert "use text data url instead of base64 for shorter encoding (#33…
theoludwig 4e011b3
build(deps): usage of v5.1.18 instead of only v5 for html-validator
theoludwig b0fac27
Merge branch 'canary' into fix/next-image-render-valid-html-w3c
styfle 88caadb
Replace space with %20
styfle a8e8a67
Remove toBase64
styfle 2a03501
Merge branch 'canary' into fix/next-image-render-valid-html-w3c
styfle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 13 additions & 0 deletions
13
test/integration/image-component/valid-w3c-html/pages/_document.js
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,13 @@ | ||
import { Html, Head, Main, NextScript } from 'next/document' | ||
|
||
export default function Document() { | ||
return ( | ||
<Html lang="en"> | ||
<Head /> | ||
<body> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</Html> | ||
) | ||
} |
18 changes: 18 additions & 0 deletions
18
test/integration/image-component/valid-w3c-html/pages/index.js
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,18 @@ | ||
import Head from 'next/head' | ||
import Image from 'next/image' | ||
|
||
export default function Home() { | ||
return ( | ||
<div> | ||
<Head> | ||
<title>Create Next App</title> | ||
<meta name="description" content="Generated by create next app" /> | ||
<link rel="icon" type="image/jpeg" href="/test.jpg" /> | ||
</Head> | ||
|
||
<main> | ||
<Image src="/test.jpg" alt="logo" width={200} height={200} /> | ||
</main> | ||
</div> | ||
) | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions
42
test/integration/image-component/valid-w3c-html/test/index.test.js
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,42 @@ | ||
/* eslint-env jest */ | ||
|
||
import { | ||
findPort, | ||
killApp, | ||
nextBuild, | ||
nextStart, | ||
waitFor, | ||
} from 'next-test-utils' | ||
import webdriver from 'next-webdriver' | ||
import validateHTML from 'html-validator' | ||
import { join } from 'path' | ||
|
||
const appDir = join(__dirname, '../') | ||
let appPort | ||
let app | ||
let browser | ||
|
||
describe('Image Component Valid W3C HTML', () => { | ||
beforeAll(async () => { | ||
await nextBuild(appDir) | ||
appPort = await findPort() | ||
app = await nextStart(appDir, appPort) | ||
browser = await webdriver(appPort, '/') | ||
}) | ||
afterAll(() => { | ||
killApp(app) | ||
browser = null | ||
}) | ||
|
||
it('should be vaild W3C HTML', async () => { | ||
await waitFor(1000) | ||
expect(await browser.hasElementByCssSelector('img')).toBeTruthy() | ||
const url = await browser.url() | ||
const result = await validateHTML({ | ||
url, | ||
format: 'json', | ||
isLocal: true, | ||
}) | ||
expect(result.messages).toEqual([]) | ||
}) | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add this to the existing image-component test suite here instead and ensure the different layouts all validate correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, done! 👍
To keep things simple, I still added a new page
/valid-html-w3c
in thedefault
folder.