-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1285 from TehShrike/backtick-literals-in-svg-prop…
…erty Fix backtick string literals not being recognized in the svg/tag/props properties
- Loading branch information
Showing
13 changed files
with
102 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
test/runtime/samples/svg-child-component-declared-namespace-backtick-string/Rect.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,7 @@ | ||
<rect x='{{x}}' y='{{y}}' width='{{width}}' height='{{height}}'/> | ||
|
||
<script> | ||
export default { | ||
namespace: `svg` | ||
}; | ||
</script> |
21 changes: 21 additions & 0 deletions
21
test/runtime/samples/svg-child-component-declared-namespace-backtick-string/_config.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,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>` ); | ||
}, | ||
}; |
11 changes: 11 additions & 0 deletions
11
test/runtime/samples/svg-child-component-declared-namespace-backtick-string/main.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,11 @@ | ||
<svg> | ||
<Rect x='{{x}}' y='{{y}}' width='{{width}}' height='{{height}}'/> | ||
</svg> | ||
|
||
<script> | ||
import Rect from './Rect.html'; | ||
|
||
export default { | ||
components: { Rect } | ||
}; | ||
</script> |
12 changes: 12 additions & 0 deletions
12
test/validator/samples/properties-props-must-be-an-array/errors.json
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 @@ | ||
[{ | ||
"message": "'props' must be an array expression, if specified", | ||
"loc": { | ||
"line": 5, | ||
"column": 9 | ||
}, | ||
"end": { | ||
"line": 5, | ||
"column": 11 | ||
}, | ||
"pos": 49 | ||
}] |
7 changes: 7 additions & 0 deletions
7
test/validator/samples/properties-props-must-be-an-array/input.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,7 @@ | ||
<div></div> | ||
|
||
<script> | ||
export default { | ||
props: {} | ||
}; | ||
</script> |
12 changes: 12 additions & 0 deletions
12
test/validator/samples/properties-props-must-be-array-of-strings/errors.json
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 @@ | ||
[{ | ||
"message": "'props' must be an array of string literals", | ||
"loc": { | ||
"line": 5, | ||
"column": 10 | ||
}, | ||
"end": { | ||
"line": 5, | ||
"column": 12 | ||
}, | ||
"pos": 50 | ||
}] |
7 changes: 7 additions & 0 deletions
7
test/validator/samples/properties-props-must-be-array-of-strings/input.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,7 @@ | ||
<div></div> | ||
|
||
<script> | ||
export default { | ||
props: [{}] | ||
}; | ||
</script> |