-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* add test * create svg element if {@html} tag is inside of svg * always use claim_html_tag
- Loading branch information
1 parent
eb37f4a
commit 1803290
Showing
9 changed files
with
168 additions
and
15 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
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,35 @@ | ||
export default { | ||
html: ` | ||
<svg width="100" height="60"> | ||
<circle cx="25" cy="30" r="24" fill="#FFD166"></circle> | ||
<circle cx="75" cy="30" r="24" fill="#118AB2"></circle> | ||
</svg> | ||
`, | ||
test({ assert, target, component }) { | ||
|
||
let svg = target.querySelector('svg'); | ||
let circles = target.querySelectorAll('circle'); | ||
assert.equal(svg.namespaceURI, 'http://www.w3.org/2000/svg'); | ||
assert.equal(2, circles.length); | ||
assert.equal(circles[0].namespaceURI, 'http://www.w3.org/2000/svg'); | ||
assert.equal(circles[1].namespaceURI, 'http://www.w3.org/2000/svg'); | ||
|
||
component.width = 200; | ||
component.height = 120; | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<svg width="200" height="120"> | ||
<circle cx="50" cy="60" r="24" fill="#FFD166"></circle> | ||
<circle cx="150" cy="60" r="24" fill="#118AB2"></circle> | ||
</svg> | ||
` | ||
); | ||
svg = target.querySelector('svg'); | ||
circles = target.querySelectorAll('circle'); | ||
assert.equal(svg.namespaceURI, 'http://www.w3.org/2000/svg'); | ||
assert.equal(2, circles.length); | ||
assert.equal(circles[0].namespaceURI, 'http://www.w3.org/2000/svg'); | ||
assert.equal(circles[1].namespaceURI, 'http://www.w3.org/2000/svg'); | ||
} | ||
}; |
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 @@ | ||
<script> | ||
export let width = 100 | ||
export let height = 60 | ||
$: circle = `<circle cx="${width/4}" cy="${height/2}" r="24" fill="#FFD166"/>` | ||
</script> | ||
|
||
<svg width="{width}" height="{height}"> | ||
{@html circle} | ||
<circle cx="{width/4*3}" cy="{height/2}" r="24" fill="#118AB2"/> | ||
</svg> |
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,39 @@ | ||
export default { | ||
html: ` | ||
<svg width="100" height="60"> | ||
<rect> | ||
<circle cx="25" cy="30" r="24" fill="#FFD166"></circle> | ||
<circle cx="75" cy="30" r="24" fill="#118AB2"></circle> | ||
</rect> | ||
</svg> | ||
`, | ||
test({ assert, target, component }) { | ||
|
||
let svg = target.querySelector('svg'); | ||
let circles = target.querySelectorAll('circle'); | ||
assert.equal(svg.namespaceURI, 'http://www.w3.org/2000/svg'); | ||
assert.equal(2, circles.length); | ||
assert.equal(circles[0].namespaceURI, 'http://www.w3.org/2000/svg'); | ||
assert.equal(circles[1].namespaceURI, 'http://www.w3.org/2000/svg'); | ||
|
||
component.width = 200; | ||
component.height = 120; | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<svg width="200" height="120"> | ||
<rect> | ||
<circle cx="50" cy="60" r="24" fill="#FFD166"></circle> | ||
<circle cx="150" cy="60" r="24" fill="#118AB2"></circle> | ||
</rect> | ||
</svg> | ||
` | ||
); | ||
svg = target.querySelector('svg'); | ||
circles = target.querySelectorAll('circle'); | ||
assert.equal(svg.namespaceURI, 'http://www.w3.org/2000/svg'); | ||
assert.equal(2, circles.length); | ||
assert.equal(circles[0].namespaceURI, 'http://www.w3.org/2000/svg'); | ||
assert.equal(circles[1].namespaceURI, 'http://www.w3.org/2000/svg'); | ||
} | ||
}; |
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 @@ | ||
<script> | ||
export let width = 100 | ||
export let height = 60 | ||
$: circle = `<circle cx="${width/4}" cy="${height/2}" r="24" fill="#FFD166"/>` | ||
</script> | ||
|
||
<svg width="{width}" height="{height}"> | ||
<rect> | ||
{@html circle} | ||
<circle cx="{width/4*3}" cy="{height/2}" r="24" fill="#118AB2"/> | ||
</rect> | ||
</svg> |
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,33 @@ | ||
export default { | ||
html: ` | ||
<svg> | ||
<foreignObject> | ||
<circle cx="25" cy="30" r="24" fill="#FFD166"></circle> | ||
</foreignObject> | ||
</svg> | ||
`, | ||
test({ assert, target, component }) { | ||
|
||
let svg = target.querySelector('svg'); | ||
let circle = target.querySelector('circle'); | ||
assert.equal(svg.namespaceURI, 'http://www.w3.org/2000/svg'); | ||
assert.equal(circle.namespaceURI, 'http://www.w3.org/1999/xhtml'); | ||
|
||
component.width = 200; | ||
component.height = 120; | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<svg> | ||
<foreignObject> | ||
<circle cx="50" cy="60" r="24" fill="#FFD166"></circle> | ||
</foreignObject> | ||
</svg> | ||
` | ||
); | ||
svg = target.querySelector('svg'); | ||
circle = target.querySelector('circle'); | ||
assert.equal(svg.namespaceURI, 'http://www.w3.org/2000/svg'); | ||
assert.equal(circle.namespaceURI, 'http://www.w3.org/1999/xhtml'); | ||
} | ||
}; |
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,11 @@ | ||
<script> | ||
export let width = 100 | ||
export let height = 60 | ||
$: circle = `<circle cx="${width/4}" cy="${height/2}" r="24" fill="#FFD166"/>` | ||
</script> | ||
|
||
<svg> | ||
<foreignObject> | ||
{@html circle} | ||
</foreignObject> | ||
</svg> |