Skip to content
This repository has been archived by the owner on Mar 20, 2021. It is now read-only.

Fix for issue #296 #297

Merged
merged 9 commits into from
Jan 15, 2014
Merged

Fix for issue #296 #297

merged 9 commits into from
Jan 15, 2014

Conversation

solidgoldpig
Copy link
Contributor

IE11 - nested views are not preserved in DOM when rerendered
#296

@eastridge
Copy link
Contributor

@solidgoldpig In addition to complimenting you on your amazing username, I'd like to thank you for this PR. @kpdecker do you have any profiling set up on any mweb projects where we could see the impact of this change? First thought is that if there is any impact we can do a conditional for IE, else use innerHTML

@solidgoldpig
Copy link
Contributor Author

I did think of putting in a conditional for IE11, but seeing that the only way appears to be matching navigator.agent for /Trident7./ I steered clear of it. Obviously, I understand if my personal dislike for that solution is trumped by considerations of real world performance.

I also considered using this.$el.empty() but that would not only be slower, but would also require any events on the nested views to be redelegated when reinserted.

Thanks for Thorax - love its opinionatedness ;)

@kpdecker
Copy link
Contributor

It seems like this should go into the ie.js source file rather than the normal impl.

@eastridge
Copy link
Contributor

@solidgoldpig would you mind trying to move to our ie.js?

@@ -1,5 +1,6 @@
/*global _replaceHTML */
var isIE = (/msie [\w.]+/).exec(navigator.userAgent.toLowerCase());
var isIE11 = !!navigator.userAgent.match(/Trident\/7\./);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check for IE11 is just a horrible regex against navigator.userAgent.

Perhaps rather than testing for the user string here, it would make more sense to do quasi-feature detection?

  • create a view with a nested view
  • update the view
  • check to see if the nested view still exists
  • update the methods if it doesn't

@solidgoldpig
Copy link
Contributor Author

I've moved the fix to ie.js.

I now realise that Thorax.View.on('before:append'... block no longer seems to be needed in IEs 9 and 10. On the other hand, without the overridden _replaceHTML, IEs 9 and 10 both fail the "view helper - ensure manually initialized child view is not destroyed if it goes out of scope in template" test.

}

// IEs 9, 10 and 11 will lose references to nested views if view.el.innerHTML = '';
// Fixes issue #296
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@solidgoldpig can you make this a full URL to the ticket?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eastridge Done

@eastridge
Copy link
Contributor

@solidgoldpig looks good to me! Thanks so much.

@kpdecker Does this look ok to you now?

kpdecker added a commit that referenced this pull request Jan 15, 2014
@kpdecker kpdecker merged commit 461180a into walmartlabs:master Jan 15, 2014
@kpdecker
Copy link
Contributor

Released in 2.3.2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants