-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for declared namespaces – fixes #147
- Loading branch information
1 parent
7f392e5
commit fbe1308
Showing
17 changed files
with
123 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,8 @@ | ||
export const html = 'http://www.w3.org/1999/xhtml'; | ||
export const mathml = 'http://www.w3.org/1998/Math/MathML'; | ||
export const svg = 'http://www.w3.org/2000/svg'; | ||
export const xlink = 'http://www.w3.org/1999/xlink'; | ||
export const xml = 'http://www.w3.org/XML/1998/namespace'; | ||
export const xmlns = 'http://www.w3.org/2000/xmlns'; | ||
|
||
export default { html, mathml, svg, xlink, xml, xmlns }; |
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
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,5 @@ | ||
export default function namespace ( validator, prop ) { | ||
if ( prop.value.type !== 'Literal' || typeof prop.value.value !== 'string' ) { | ||
validator.error( `The 'namespace' property must be a string literal representing a valid namespace`, prop.start ); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
test/generator/svg-child-component-declared-namespace-shorthand/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> |
3 changes: 2 additions & 1 deletion
3
.../generator/svg-child-component/_config.js → ...t-declared-namespace-shorthand/_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
1 change: 1 addition & 0 deletions
1
test/generator/svg-child-component/main.html → ...nt-declared-namespace-shorthand/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
7 changes: 7 additions & 0 deletions
7
test/generator/svg-child-component-declared-namespace/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: 'http://www.w3.org/2000/svg' | ||
}; | ||
</script> |
21 changes: 21 additions & 0 deletions
21
test/generator/svg-child-component-declared-namespace/_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/generator/svg-child-component-declared-namespace/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> |
7 changes: 7 additions & 0 deletions
7
test/validator/svg-child-component-declared-namespace/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 @@ | ||
<rect x='{{x}}' y='{{y}}' width='{{width}}' height='{{height}}'/> | ||
|
||
<script> | ||
export default { | ||
namespace: 'svg' | ||
}; | ||
</script> |
1 change: 1 addition & 0 deletions
1
test/validator/svg-child-component-declared-namespace/warnings.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 @@ | ||
[] |
File renamed without changes.
8 changes: 8 additions & 0 deletions
8
test/validator/svg-child-component-undeclared-namespace/warnings.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,8 @@ | ||
[{ | ||
"message": "<rect> is an SVG element – did you forget to add { namespace: 'svg' } ?", | ||
"loc": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"pos": 0 | ||
}] |