[#1976] Add support for the replaceElement option on Region #1980
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.
NOTE: I'll try to write the specs this evening and push them up. I just wanted to get the code in front of you guys for further discussion.
I'll reiterate my approach from the #1976:
region.el
, I'm simply replacing the element in the DOM withregion.replaceEl()
andregion.restoreEl()
.region.el
stays in tact.region.show( view, { replaceElement: true })
I am settingregion.replaced
. This allows all future executions on region to determine if they need to addressregion.el
orview.el
.region.empty()
I am checking the value ofregion.replaced
. If it's true, I'll replace theview.el
withregion.el
before destroying the view. This way any future executions onregion.el
will refer to the correct node.TO DO
replaceEl()
andrestoreEl()
can probably be abstracted just a little more but I don't know that it's really necessary.This needs WAY more testing. I only beat on it with
region.show()
,region.empty()
, andregion.reset()
.