This fixes an issue when using removeGlobalContexts to remove a context generator function when multiple generator functions have been added.
In 3.0.0 the method of identifying the ContextPrimitive to remove was changed from equality/identity to comparing the JSON serialization of the entities. Unfortunately, this doesn't handle the generator function case, because JSON.stringify(function(){}) returns undefined, which means all added context generators appear identical, so removing one generator actually removes all of them.
This changes the comparison to be identity-based for functions, and remain JSON-based for static entities.
It also fixes matching on for ConditionalContextProviders by implementing a deep comparison. A purely identity-based approach is much simpler, but only a partial solution; non-identical providers with the same static entities added with different filter functions would still collide if the identities of the array don't match correctly.
This fixes an issue when using
removeGlobalContexts
to remove a context generator function when multiple generator functions have been added.In 3.0.0 the method of identifying the
ContextPrimitive
to remove was changed from equality/identity to comparing the JSON serialization of the entities. Unfortunately, this doesn't handle the generator function case, becauseJSON.stringify(function(){})
returnsundefined
, which means all added context generators appear identical, so removing one generator actually removes all of them.This changes the comparison to be identity-based for functions, and remain JSON-based for static entities.
It also fixes matching on for
ConditionalContextProviders
by implementing a deep comparison. A purely identity-based approach is much simpler, but only a partial solution; non-identical providers with the same static entities added with different filter functions would still collide if the identities of the array don't match correctly.