xml-model 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,13 +40,13 @@ exports.defaults = {
40
40
  // TODO: handle inline
41
41
  const prop = context.property;
42
42
  const elements = context.elements;
43
+ if (prop.reflected.isOptional && elements.length === 0) {
44
+ return undefined;
45
+ }
43
46
  if (prop.model) {
44
47
  return prop.model.fromXML({ elements });
45
48
  }
46
49
  const type = context.property.reflected.type;
47
- if (prop.reflected.isOptional && elements.length === 0) {
48
- return undefined;
49
- }
50
50
  if (type.is("class")) {
51
51
  const model = (0, model_1.getModel)(type.class);
52
52
  return model.fromXML({ elements: context.elements });
@@ -123,14 +123,14 @@ exports.defaults = {
123
123
  },
124
124
  propertyToXML(context) {
125
125
  const property = context.property;
126
- if (property.model) {
127
- return property.model.toXML(context.value);
128
- }
129
126
  const type = property.reflected.type;
130
127
  const value = context.value;
131
128
  if (property.reflected.isOptional && typeof value === "undefined") {
132
129
  return { elements: [] }; // FIXME should return unefined ???
133
130
  }
131
+ if (property.model) {
132
+ return property.model.toXML(value);
133
+ }
134
134
  const getXML = () => {
135
135
  if (type.is("class")) {
136
136
  const model = (0, model_1.getModel)(type.class);
@@ -34,13 +34,13 @@ export const defaults = {
34
34
  // TODO: handle inline
35
35
  const prop = context.property;
36
36
  const elements = context.elements;
37
+ if (prop.reflected.isOptional && elements.length === 0) {
38
+ return undefined;
39
+ }
37
40
  if (prop.model) {
38
41
  return prop.model.fromXML({ elements });
39
42
  }
40
43
  const type = context.property.reflected.type;
41
- if (prop.reflected.isOptional && elements.length === 0) {
42
- return undefined;
43
- }
44
44
  if (type.is("class")) {
45
45
  const model = getModel(type.class);
46
46
  return model.fromXML({ elements: context.elements });
@@ -117,14 +117,14 @@ export const defaults = {
117
117
  },
118
118
  propertyToXML(context) {
119
119
  const property = context.property;
120
- if (property.model) {
121
- return property.model.toXML(context.value);
122
- }
123
120
  const type = property.reflected.type;
124
121
  const value = context.value;
125
122
  if (property.reflected.isOptional && typeof value === "undefined") {
126
123
  return { elements: [] }; // FIXME should return unefined ???
127
124
  }
125
+ if (property.model) {
126
+ return property.model.toXML(value);
127
+ }
128
128
  const getXML = () => {
129
129
  if (type.is("class")) {
130
130
  const model = getModel(type.class);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xml-model",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "main": "build/main/index.js",
5
5
  "typings": "build/main/index.d.ts",
6
6
  "module": "build/module/index.js",