mirror of https://github.com/sveltejs/svelte
Merge pull request #1285 from TehShrike/backtick-literals-in-svg-property
Fix backtick string literals not being recognized in the svg/tag/props propertiespull/1293/head
commit
565bc52423
@ -0,0 +1,11 @@
|
||||
import { Node } from '../interfaces';
|
||||
|
||||
export default function nodeToString(node: Node) {
|
||||
if (node.type === 'Literal' && typeof node.value === 'string') {
|
||||
return node.value;
|
||||
} else if (node.type === 'TemplateLiteral'
|
||||
&& node.quasis.length === 1
|
||||
&& node.expressions.length === 0) {
|
||||
return node.quasis[0].value.raw;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<rect x='{{x}}' y='{{y}}' width='{{width}}' height='{{height}}'/>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
namespace: `svg`
|
||||
};
|
||||
</script>
|
@ -0,0 +1,21 @@
|
||||
export default {
|
||||
data: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 100,
|
||||
height: 100
|
||||
},
|
||||
|
||||
html: `<svg><rect x="0" y="0" width="100" height="100"></rect></svg>`,
|
||||
|
||||
test ( assert, component, target ) {
|
||||
const svg = target.querySelector( 'svg' );
|
||||
const rect = target.querySelector( 'rect' );
|
||||
|
||||
assert.equal( svg.namespaceURI, 'http://www.w3.org/2000/svg' );
|
||||
assert.equal( rect.namespaceURI, 'http://www.w3.org/2000/svg' );
|
||||
|
||||
component.set({ width: 150, height: 50 });
|
||||
assert.equal( target.innerHTML, `<svg><rect x="0" y="0" width="150" height="50"></rect></svg>` );
|
||||
},
|
||||
};
|
After Width: | Height: | Size: 179 B |
@ -0,0 +1,12 @@
|
||||
[{
|
||||
"message": "'props' must be an array expression, if specified",
|
||||
"loc": {
|
||||
"line": 5,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 11
|
||||
},
|
||||
"pos": 49
|
||||
}]
|
@ -0,0 +1,7 @@
|
||||
<div></div>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,12 @@
|
||||
[{
|
||||
"message": "'props' must be an array of string literals",
|
||||
"loc": {
|
||||
"line": 5,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 12
|
||||
},
|
||||
"pos": 50
|
||||
}]
|
@ -0,0 +1,7 @@
|
||||
<div></div>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: [{}]
|
||||
};
|
||||
</script>
|
Loading…
Reference in new issue