-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix x-ignore being added after using Alpine.morph (#47)
* Add failing test * Do not rerun x-load when morphing elements
- Loading branch information
Showing
7 changed files
with
111 additions
and
49 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,37 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta name="description" content=""> | ||
<title>morph - Async Alpine tests</title> | ||
</head> | ||
<body> | ||
<p>Tests Alpine 'morph'. Passes if x-ignore is not re-added after morphing (pressing 'Run Morph' button).</p> | ||
|
||
<div | ||
data-testid="test" | ||
x-load | ||
x-load-src="/tests/assets/complex.js" | ||
x-data="complex" | ||
x-text="'testing123'" | ||
> | ||
</div> | ||
|
||
<button data-testid="button">Run morph</button> | ||
|
||
<script type="module"> | ||
import Alpine from 'https://cdn.skypack.dev/alpinejs' | ||
import AsyncAlpine from '/dist/async-alpine.esm.js' | ||
import AlpineMorph from 'https://cdn.skypack.dev/@alpinejs/morph' | ||
Alpine.plugin(AsyncAlpine) | ||
Alpine.plugin(AlpineMorph) | ||
Alpine.start() | ||
window.Alpine = Alpine // Alpine morph plugin needs Alpine as a global | ||
|
||
document.querySelector('button').addEventListener('click', () => { | ||
Alpine.morph(document.querySelector('div'), document.querySelector('div').outerHTML) | ||
}) | ||
</script> | ||
</body> | ||
</html> |
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,12 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('alpine/morph', async ({ page }) => { | ||
await page.goto('/tests/alpine/morph/') | ||
await expect(page.getByTestId('test')) | ||
.toHaveText('testing123') | ||
await page.getByTestId('button').click() | ||
await expect(page.getByTestId('test')) | ||
.not.toHaveAttribute('x-ignore') | ||
await expect(page.getByTestId('test')) | ||
.toHaveText('testing123') | ||
}); |
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