ember-data-model-fragments 6.0.2 → 6.0.4

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.
package/CHANGELOG.md CHANGED
@@ -11,6 +11,24 @@
11
11
 
12
12
 
13
13
 
14
+
15
+
16
+ ## v6.0.4 (2023-09-01)
17
+
18
+ #### :bug: Bug Fix
19
+ * [#479](https://github.com/adopted-ember-addons/ember-data-model-fragments/pull/479) Add `copy` to type declarations ([@charlesfries](https://github.com/charlesfries))
20
+
21
+ #### Committers: 1
22
+ - Charles Fries ([@charlesfries](https://github.com/charlesfries))
23
+
24
+ ## v6.0.3 (2023-07-20)
25
+
26
+ #### :bug: Bug Fix
27
+ * [#476](https://github.com/adopted-ember-addons/ember-data-model-fragments/pull/476) changedAttributes still return the dirty attributes until the record has been fully committed ([@VincentMolinie](https://github.com/VincentMolinie))
28
+
29
+ #### Committers: 1
30
+ - Vincent Molinié ([@VincentMolinie](https://github.com/VincentMolinie))
31
+
14
32
  ## v6.0.2 (2023-07-15)
15
33
 
16
34
  #### :bug: Bug Fix
@@ -618,9 +618,7 @@ export default class FragmentRecordData extends RecordData {
618
618
  }
619
619
 
620
620
  hasChangedFragments() {
621
- return (
622
- this.__fragments !== null && Object.keys(this.__fragments).length > 0
623
- );
621
+ return Object.keys(this._fragmentsOrInFlight).length > 0;
624
622
  }
625
623
 
626
624
  isFragmentDirty(key) {
@@ -669,7 +667,9 @@ export default class FragmentRecordData extends RecordData {
669
667
 
670
668
  changedFragments() {
671
669
  const diffData = Object.create(null);
672
- for (const [key, newFragment] of Object.entries(this._fragments)) {
670
+ for (const [key, newFragment] of Object.entries(
671
+ this._fragmentsOrInFlight
672
+ )) {
673
673
  const behavior = this._fragmentBehavior[key];
674
674
  const oldFragment =
675
675
  key in this._inFlightFragments
@@ -1053,6 +1053,13 @@ export default class FragmentRecordData extends RecordData {
1053
1053
  this.__inFlightFragments = v;
1054
1054
  }
1055
1055
 
1056
+ get _fragmentsOrInFlight() {
1057
+ return this.__inFlightFragments &&
1058
+ Object.keys(this.__inFlightFragments).length > 0
1059
+ ? this.__inFlightFragments
1060
+ : this.__fragments || {};
1061
+ }
1062
+
1056
1063
  /**
1057
1064
  * Fragment array instances
1058
1065
  *
package/fragment.d.ts CHANGED
@@ -2,4 +2,5 @@ import Model from '@ember-data/model';
2
2
 
3
3
  export default class Fragment extends Model {
4
4
  _isFragment: true;
5
+ copy: () => this;
5
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-data-model-fragments",
3
- "version": "6.0.2",
3
+ "version": "6.0.4",
4
4
  "description": "Ember Data addon to support nested JSON documents",
5
5
  "keywords": [
6
6
  "ember-addon",