✨ Added support for xml:lang attribute in SVG tag
This commit is contained in:
parent
1a029b7ac3
commit
0a1d96ea22
5 changed files with 53 additions and 16 deletions
|
@ -22,7 +22,9 @@ export default function Pattern(config = false) {
|
||||||
// Data containers
|
// Data containers
|
||||||
this.settings = {
|
this.settings = {
|
||||||
mode: "draft",
|
mode: "draft",
|
||||||
idPrefix: "fs-"
|
idPrefix: "fs-",
|
||||||
|
locale: "en",
|
||||||
|
units: "metric"
|
||||||
};
|
};
|
||||||
this.options = {};
|
this.options = {};
|
||||||
this.store = new Store();
|
this.store = new Store();
|
||||||
|
@ -31,8 +33,7 @@ export default function Pattern(config = false) {
|
||||||
// Merge config with defaults
|
// Merge config with defaults
|
||||||
let defaults = {
|
let defaults = {
|
||||||
measurements: {},
|
measurements: {},
|
||||||
options: {},
|
options: {}
|
||||||
units: "metric"
|
|
||||||
};
|
};
|
||||||
this.config = { ...defaults, ...config };
|
this.config = { ...defaults, ...config };
|
||||||
for (let i in config.options) {
|
for (let i in config.options) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ function Svg(pattern) {
|
||||||
this.attributes.add("xmlns", "http://www.w3.org/2000/svg");
|
this.attributes.add("xmlns", "http://www.w3.org/2000/svg");
|
||||||
this.attributes.add("xmlns:svg", "http://www.w3.org/2000/svg");
|
this.attributes.add("xmlns:svg", "http://www.w3.org/2000/svg");
|
||||||
this.attributes.add("xmlns:xlink", "http://www.w3.org/1999/xlink");
|
this.attributes.add("xmlns:xlink", "http://www.w3.org/1999/xlink");
|
||||||
|
this.attributes.add("xml:lang", pattern.settings.locale);
|
||||||
this.attributes.add(
|
this.attributes.add(
|
||||||
"xmlns:freesewing",
|
"xmlns:freesewing",
|
||||||
"http://freesewing.org/namespaces/freesewing"
|
"http://freesewing.org/namespaces/freesewing"
|
||||||
|
|
53
tests/fixtures/render.js
vendored
53
tests/fixtures/render.js
vendored
|
@ -6,7 +6,36 @@ var render = {
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
--><svg
|
--><svg
|
||||||
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="0mm" height="0mm" viewBox="0 0 0 0"
|
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:lang="en" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="0mm" height="0mm" viewBox="0 0 0 0"
|
||||||
|
>
|
||||||
|
<style type="text/css"> <![CDATA[
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</style>
|
||||||
|
<script type="text/javascript"> <![CDATA[
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</script>
|
||||||
|
<defs>
|
||||||
|
|
||||||
|
</defs>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Start of group #fs-container -->
|
||||||
|
<g id="fs-container">
|
||||||
|
</g>
|
||||||
|
<!-- end of group #fs-container -->
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
|
-->`,
|
||||||
|
boilerplateNl: `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
|
--><svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:lang="nl" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="0mm" height="0mm" viewBox="0 0 0 0"
|
||||||
>
|
>
|
||||||
<style type="text/css"> <![CDATA[
|
<style type="text/css"> <![CDATA[
|
||||||
|
|
||||||
|
@ -35,7 +64,7 @@ var render = {
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
--><svg
|
--><svg
|
||||||
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" viewBox="0 0 0 0"
|
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:lang="en" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" viewBox="0 0 0 0"
|
||||||
>
|
>
|
||||||
<style type="text/css"> <![CDATA[
|
<style type="text/css"> <![CDATA[
|
||||||
|
|
||||||
|
@ -64,7 +93,7 @@ var render = {
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
--><svg
|
--><svg
|
||||||
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="20mm" height="20mm" viewBox="0 0 20 20"
|
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:lang="en" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="20mm" height="20mm" viewBox="0 0 20 20"
|
||||||
>
|
>
|
||||||
<style type="text/css"> <![CDATA[
|
<style type="text/css"> <![CDATA[
|
||||||
|
|
||||||
|
@ -98,7 +127,7 @@ var render = {
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
--><svg
|
--><svg
|
||||||
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="60mm" height="72.45mm" viewBox="0 0 60 72.45"
|
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:lang="en" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="60mm" height="72.45mm" viewBox="0 0 60 72.45"
|
||||||
>
|
>
|
||||||
<style type="text/css"> <![CDATA[
|
<style type="text/css"> <![CDATA[
|
||||||
|
|
||||||
|
@ -133,7 +162,7 @@ var render = {
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
--><svg
|
--><svg
|
||||||
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="20mm" height="20mm" viewBox="0 0 20 20"
|
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:lang="en" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="20mm" height="20mm" viewBox="0 0 20 20"
|
||||||
>
|
>
|
||||||
<style type="text/css"> <![CDATA[
|
<style type="text/css"> <![CDATA[
|
||||||
|
|
||||||
|
@ -169,7 +198,7 @@ var render = {
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
--><svg
|
--><svg
|
||||||
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="120mm" height="120mm" viewBox="0 0 120 120"
|
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:lang="en" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="120mm" height="120mm" viewBox="0 0 120 120"
|
||||||
>
|
>
|
||||||
<style type="text/css"> <![CDATA[
|
<style type="text/css"> <![CDATA[
|
||||||
|
|
||||||
|
@ -208,7 +237,7 @@ var render = {
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
--><svg
|
--><svg
|
||||||
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="20mm" height="20mm" viewBox="0 0 20 20"
|
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:lang="en" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="20mm" height="20mm" viewBox="0 0 20 20"
|
||||||
>
|
>
|
||||||
<style type="text/css"> <![CDATA[
|
<style type="text/css"> <![CDATA[
|
||||||
|
|
||||||
|
@ -244,7 +273,7 @@ var render = {
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
--><svg
|
--><svg
|
||||||
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="20mm" height="20mm" viewBox="0 0 20 20"
|
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:lang="en" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="20mm" height="20mm" viewBox="0 0 20 20"
|
||||||
>
|
>
|
||||||
<style type="text/css"> <![CDATA[
|
<style type="text/css"> <![CDATA[
|
||||||
|
|
||||||
|
@ -280,7 +309,7 @@ var render = {
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
--><svg
|
--><svg
|
||||||
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="60mm" height="72.45mm" viewBox="0 0 60 72.45"
|
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:lang="en" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="60mm" height="72.45mm" viewBox="0 0 60 72.45"
|
||||||
>
|
>
|
||||||
<style type="text/css"> <![CDATA[
|
<style type="text/css"> <![CDATA[
|
||||||
|
|
||||||
|
@ -317,7 +346,7 @@ var render = {
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
--><svg
|
--><svg
|
||||||
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="60mm" height="72.45mm" viewBox="0 0 60 72.45"
|
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:lang="en" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="60mm" height="72.45mm" viewBox="0 0 60 72.45"
|
||||||
>
|
>
|
||||||
<style type="text/css"> <![CDATA[
|
<style type="text/css"> <![CDATA[
|
||||||
|
|
||||||
|
@ -354,7 +383,7 @@ var render = {
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
--><svg
|
--><svg
|
||||||
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="60mm" height="72.45mm" viewBox="0 0 60 72.45"
|
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:lang="en" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="60mm" height="72.45mm" viewBox="0 0 60 72.45"
|
||||||
>
|
>
|
||||||
<style type="text/css"> <![CDATA[
|
<style type="text/css"> <![CDATA[
|
||||||
|
|
||||||
|
@ -391,7 +420,7 @@ var render = {
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
--><svg
|
--><svg
|
||||||
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="20mm" height="20mm" viewBox="0 0 20 20"
|
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:lang="en" xmlns:freesewing="http://freesewing.org/namespaces/freesewing" freesewing="${version}" width="20mm" height="20mm" viewBox="0 0 20 20"
|
||||||
>
|
>
|
||||||
<style type="text/css"> <![CDATA[
|
<style type="text/css"> <![CDATA[
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ it("Pattern constructor should initialize object", () => {
|
||||||
expect(pattern.height).to.equal(false);
|
expect(pattern.height).to.equal(false);
|
||||||
expect(pattern.settings.mode).to.equal("draft");
|
expect(pattern.settings.mode).to.equal("draft");
|
||||||
expect(pattern.parts).to.eql({});
|
expect(pattern.parts).to.eql({});
|
||||||
expect(pattern.config.units).to.equal("metric");
|
expect(pattern.settings.units).to.equal("metric");
|
||||||
expect(pattern.config.foo).to.equal("bar");
|
expect(pattern.config.foo).to.equal("bar");
|
||||||
expect(pattern.options.constant).to.equal(2);
|
expect(pattern.options.constant).to.equal(2);
|
||||||
expect(pattern.options.percentage).to.equal(0.3);
|
expect(pattern.options.percentage).to.equal(0.3);
|
||||||
|
|
|
@ -39,6 +39,12 @@ it("Should render Svg boilerplate", () => {
|
||||||
expect(pattern.render()).to.equalIgnoreSpaces(render.boilerplate);
|
expect(pattern.render()).to.equalIgnoreSpaces(render.boilerplate);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("Should render language attribute", () => {
|
||||||
|
let pattern = new freesewing.Pattern();
|
||||||
|
pattern.settings.locale = "nl";
|
||||||
|
expect(pattern.render()).to.equalIgnoreSpaces(render.boilerplateNl);
|
||||||
|
});
|
||||||
|
|
||||||
it("Should render Svg boilerplate for embedding", () => {
|
it("Should render Svg boilerplate for embedding", () => {
|
||||||
let pattern = new freesewing.Pattern();
|
let pattern = new freesewing.Pattern();
|
||||||
pattern.settings.embed = true;
|
pattern.settings.embed = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue