Remove the use of proxies in favor of modules #895
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changed?
Modal stacking and local store features are written to take advantage of the Proxy object API. This became an issue since Proxy is not supported in IE11 and the polyfill has some major limitations. This PR refactors stack and local store features into modules with their own APIs for handling a private array and object internally.
localStore
Used to maintain a JSON object in local storage. This is a
@vrembem/core
module used by the drawer component to maintain persistent drawer states via local storage.localStore
takes a string key name parameter used to save the object in local storage. Once instantiated, the following API is returned:set(prop, value)
- Sets a prop/value pair to the stored object. Omitting avalue
parameter will delete the property. This method triggers the local storage update.get(key)
- Returns the value of a property on the stored object. Omittingkey
will return the entire stored object.Usage
stack
The stack module is stored as a property of the instantiated modal object. This can be accessed under the
.stack
property and makes available the following API:value
- Returns the current stack array. This is a returned copy and not a reference to prevent the array from being modified directly.top
- Returns the entry at top of stack (the currently active modal). This is also aliased tomodal.active
.updateIndex()
- Updated the z-index styles for all entries in the array based on their current sort.updateGlobalState()
- Updates the global state based on whether or not there is an active modal. Will also update the z-index of entries.add(entry)
- Adds an entry to the top of the stack array.remove(entry)
- Removes an entry from the stack array.moveToTop(entry)
- Will move an entry to the top of the stack if it's already in the stack array.The stack module is used internally whenever a modal is opened, closed or deregistered but the API is also available under the
stack
property of the instantiated modal object.Usage