Skip to content

Commit

Permalink
Minor internal refactoring to make things a little clearer.
Browse files Browse the repository at this point in the history
  • Loading branch information
William Troup committed Jan 8, 2024
1 parent 0a872ae commit cd28ecf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
5 changes: 2 additions & 3 deletions dist/observe.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@
}
}
function compareWatchObjectProperties(oldObject, newObject, watch) {
var options = watch.options;
var propertyName;
for (propertyName in oldObject) {
if (oldObject.hasOwnProperty(propertyName)) {
Expand All @@ -159,11 +158,11 @@
propertyNewValue = newObject[propertyName];
}
if (isDefinedObject(propertyOldValue) && isDefinedObject(propertyNewValue)) {
compareWatchObjectProperties(propertyOldValue, propertyNewValue, options);
compareWatchObjectProperties(propertyOldValue, propertyNewValue, watch.options);
} else {
if (!isDefinedArray(watch.options.propertyNames) || watch.options.propertyNames.indexOf(propertyName) > -1) {
if (JSON.stringify(propertyOldValue) !== JSON.stringify(propertyNewValue)) {
fireCustomTrigger(options.onPropertyChange, propertyName, propertyOldValue, propertyNewValue);
fireCustomTrigger(watch.options.onPropertyChange, propertyName, propertyOldValue, propertyNewValue);
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions dist/observe.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion docs/CHANGE_LOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Observe.js - Change Log:

## Version 0.6.0:
-

#### **General Improvements:**
- Minor internal refactoring to make things a little clearer.

<br>

Expand Down
6 changes: 2 additions & 4 deletions src/observe.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,6 @@
}

function compareWatchObjectProperties( oldObject, newObject, watch ) {
var options = watch.options;

for ( var propertyName in oldObject ) {
if ( oldObject.hasOwnProperty( propertyName ) ) {
var propertyOldValue = oldObject[ propertyName ],
Expand All @@ -248,12 +246,12 @@
}

if ( isDefinedObject( propertyOldValue ) && isDefinedObject( propertyNewValue ) ) {
compareWatchObjectProperties( propertyOldValue, propertyNewValue, options );
compareWatchObjectProperties( propertyOldValue, propertyNewValue, watch.options );
} else {

if ( !isDefinedArray( watch.options.propertyNames ) || watch.options.propertyNames.indexOf( propertyName ) > -1 ) {
if ( JSON.stringify( propertyOldValue ) !== JSON.stringify( propertyNewValue ) ) {
fireCustomTrigger( options.onPropertyChange, propertyName, propertyOldValue, propertyNewValue );
fireCustomTrigger( watch.options.onPropertyChange, propertyName, propertyOldValue, propertyNewValue );
}
}
}
Expand Down

0 comments on commit cd28ecf

Please sign in to comment.