mirror of https://github.com/sveltejs/svelte
add support for declared namespaces – fixes #147
parent
7f392e562b
commit
fbe130835d
@ -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 };
|
@ -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 );
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<rect x='{{x}}' y='{{y}}' width='{{width}}' height='{{height}}'/>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
namespace: 'svg'
|
||||
};
|
||||
</script>
|
@ -1,12 +1,13 @@
|
||||
export default {
|
||||
skip: true,
|
||||
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' );
|
Before Width: | Height: | Size: 178 B After Width: | Height: | Size: 179 B |
@ -0,0 +1,7 @@
|
||||
<rect x='{{x}}' y='{{y}}' width='{{width}}' height='{{height}}'/>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
namespace: 'http://www.w3.org/2000/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,7 @@
|
||||
<rect x='{{x}}' y='{{y}}' width='{{width}}' height='{{height}}'/>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
namespace: 'svg'
|
||||
};
|
||||
</script>
|
@ -0,0 +1 @@
|
||||
[]
|
Loading…
Reference in new issue