Skip to content

Commit

Permalink
Deep comparison of parameters prop in Layer (#6754)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixpalmer committed Mar 31, 2022
1 parent f84198c commit 6256b9e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/core/src/lib/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const defaultProps = {
positionFormat: 'XYZ',
colorFormat: 'RGBA',

parameters: {},
parameters: {type: 'object', value: {}, optional: true, compare: true},
transitions: null,
extensions: [],
loaders: {type: 'array', value: [], optional: true, compare: true},
Expand Down
8 changes: 8 additions & 0 deletions modules/core/src/lifecycle/prop-types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {createTexture, destroyTexture} from '../utils/texture';
import {deepEqual} from '../utils/deep-equal';

import type Component from './component';

Expand Down Expand Up @@ -57,6 +58,8 @@ type ImagePropType = BasePropType & {
};
type ObjectPropType = BasePropType & {
type: 'object';
optional?: boolean;
compare?: boolean;
};
type DeprecatedProp = {
deprecatedFor?: string | string[];
Expand Down Expand Up @@ -127,6 +130,11 @@ const TYPE_DEFINITIONS = {
return propType.compare ? arrayEqual(value1, value2) : value1 === value2;
}
},
object: {
equal(value1, value2, propType: ObjectPropType) {
return propType.compare ? deepEqual(value1, value2) : value1 === value2;
}
},
function: {
validate(value, propType: FunctionPropType) {
return (propType.optional && !value) || typeof value === 'function';
Expand Down

0 comments on commit 6256b9e

Please sign in to comment.