-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 414 #425
Issue 414 #425
Conversation
//if the element doesn't belong to document DOM observe DOM to detect | ||
//when it's attached | ||
var observer = null; | ||
if (!document.contains(el)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL that document.contains
is not a standard thing: http://stackoverflow.com/questions/20557115/mocha-casperjs-headless-testing-document-contains-undefined
but if (!document.body.contains(el)) {
works fine as suggested in that SO answer. This should fix the issue with the headless tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dissagree with this answer at SO. Here you have better source:
https://developer.mozilla.org/en-US/docs/Web/API/Node/contains
It is a standard, the only remark is that IE doesn't support it for document but only for document.body.
I can change it to document.body if it solves the problem.
Anyway, I took it from this answer at SO:
http://stackoverflow.com/questions/5629684/how-to-check-if-element-exists-in-the-visible-dom/5629730#5629730
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as an alternative, you can do:
var contains = document.contains || document.body.contains;
if (!contains(el)) {
...
}
PhantomJS framework can sometimes surface issues like this; but, the pros still outweigh its cons, so we are still sticking to it. Also, any such issue will affect people trying to render views in headless mode, so it would be great if we address this even though it is a weird workaround.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't work: I get some strange Invalid invocation error in Chrome, Firefox reports different error...
But I fixed it by replacing: document.contains
with document.body.contains
thanks @piotr-gawron! See my inline comments/questions regarding some functionality and performance issues. It would also be great to be able to replicate this issue within a unit test, but I do understand it might be tricky/unfeasible to do so. But having such as a case might help us do some benchmarking and performance monitoring. On a side note: do you think it would be better if we expose an |
@armish |
…er tag that was dynamically added pileup component wasn't updated
@armish I created this PR almost a year ago. Do you plan to merge it? Or there are some issues with my code? |
hey @piotr-gawron - sorry that this fell through the cracks and I wasn't able to get back to you with my second round of reviews. I originally wanted to do some style/type cleaning up on your code before merging in, but for the last few months, I barely have the additional time to channel into pileup maintenance. Let me just take a quick look at your PRs and I will merge them in if there are no apparent red flags. Apologies for the delay. |
This PR fixes issue #414. However, there are problems with tests now. Tests works perfectly fine when
they are run in a browser, but when test are run in a console there are errors. The errors can be summarized as: object 'document' has no function 'contains'.
Can you help me with tests?
Summary of my PR: when pileup is created with 'element' that doesn't belong to DOM, observer object is created. This observer observes document object. When 'element' is added to document (or to any (grand)child) of document pileup tracks are forced to rerender by changing updateSize state of ReactElements.
Sorry for the commits comments but I have problems with lint and git in general ;/
This change is![Reviewable](https://camo.githubusercontent.com/23b05f5fb48215c989e92cc44cf6512512d083132bd3daf689867c8d9d386888/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)