Skip to content

Commit d44e3f0

Browse files
committed
fix: broken assignment
1 parent 9ba18fa commit d44e3f0

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

dist/index.cjs.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ class Parser {
124124
if (model && model.createFn) {
125125
return model.createFn(instance, loadedElement, relation => this.parse(relation, included));
126126
}
127-
const attrData = $registeredAttributes.find(e => e.klass === model?.klass);
128-
const relsData = $registeredRelationships.find(e => e.klass === model?.klass);
129127
instance.id = loadedElement.id;
130128
instance._type = loadedElement.type;
131129
if ('$_partial' in loadedElement) {
132130
return instance;
133131
}
132+
const attrData = $registeredAttributes.find(e => e.klass === model?.klass);
133+
const relsData = $registeredRelationships.find(e => e.klass === model?.klass);
134134
this.parseAttributes(instance, loadedElement, attrData);
135135
this.parseRelationships(instance, loadedElement, relsData, included);
136136
return instance;
@@ -144,6 +144,9 @@ class Parser {
144144
if (prop === "$_partial") {
145145
return true;
146146
}
147+
if (prop in target) {
148+
return target[prop];
149+
}
147150
const propString = prop.toString();
148151
debug('error', `Trying to call property "${propString}" to a model that is not included. Add "${loadedElement.type}" to included models.`, {
149152
model: instance,

dist/index.esm.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ class Parser {
120120
if (model && model.createFn) {
121121
return model.createFn(instance, loadedElement, relation => this.parse(relation, included));
122122
}
123-
const attrData = $registeredAttributes.find(e => e.klass === model?.klass);
124-
const relsData = $registeredRelationships.find(e => e.klass === model?.klass);
125123
instance.id = loadedElement.id;
126124
instance._type = loadedElement.type;
127125
if ('$_partial' in loadedElement) {
128126
return instance;
129127
}
128+
const attrData = $registeredAttributes.find(e => e.klass === model?.klass);
129+
const relsData = $registeredRelationships.find(e => e.klass === model?.klass);
130130
this.parseAttributes(instance, loadedElement, attrData);
131131
this.parseRelationships(instance, loadedElement, relsData, included);
132132
return instance;
@@ -140,6 +140,9 @@ class Parser {
140140
if (prop === "$_partial") {
141141
return true;
142142
}
143+
if (prop in target) {
144+
return target[prop];
145+
}
143146
const propString = prop.toString();
144147
debug('error', `Trying to call property "${propString}" to a model that is not included. Add "${loadedElement.type}" to included models.`, {
145148
model: instance,

src/Parser.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,20 @@ export class Parser {
6969
return model.createFn(instance, loadedElement, (relation) => this.parse(relation, included)) as T;
7070
}
7171

72+
instance.id = loadedElement.id;
73+
instance._type = loadedElement.type;
74+
75+
if ('$_partial' in loadedElement) {
76+
return instance as T;
77+
}
78+
7279
const attrData = $registeredAttributes.find(
7380
(e) => e.klass === model?.klass
7481
);
7582
const relsData = $registeredRelationships.find(
7683
(e) => e.klass === model?.klass
7784
);
7885

79-
instance.id = loadedElement.id;
80-
instance._type = loadedElement.type;
81-
82-
if ('$_partial' in loadedElement) {
83-
return instance as T;
84-
}
8586
this.parseAttributes(instance, loadedElement, attrData);
8687
this.parseRelationships(instance, loadedElement, relsData, included);
8788

@@ -99,6 +100,9 @@ export class Parser {
99100
if (prop === "$_partial") {
100101
return true;
101102
}
103+
if (prop in target) {
104+
return target[prop];
105+
}
102106
const propString = prop.toString();
103107
debug('error', `Trying to call property "${propString}" to a model that is not included. Add "${loadedElement.type}" to included models.`, {
104108
model: instance,

0 commit comments

Comments
 (0)