-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(ngAnimate): safe-guard against missing document #14633
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,9 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) { | |
var activeAnimationsLookup = new $$HashMap(); | ||
var disabledElementsLookup = new $$HashMap(); | ||
var animationsEnabled = null; | ||
// $document might be mocked and won't include a real document. | ||
// Providing an empty object will prevent property read errors | ||
var rawDocument = $document[0] || {}; | ||
|
||
function postDigestTaskFactory() { | ||
var postDigestCalled = false; | ||
|
@@ -331,7 +334,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) { | |
|
||
var isStructural = ['enter', 'move', 'leave'].indexOf(event) >= 0; | ||
|
||
var documentHidden = animationsEnabled && $document[0].hidden; | ||
var documentHidden = rawDocument.hidden; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you also need to include There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ThomasBurleson - that was a hack by @IgorMinar to get the tests passing in G3 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean "not need"? animationsEnabled was added by Igor to fix a test in the g3 sync, but as I wrote in the commit message, this doesn't actually prevent the access to the document in all cases. If animations are enabled, $document[0] is still checked, and it might still be undefined |
||
|
||
// this is a hard disable of all animations for the application or on | ||
// the element itself, therefore there is no need to continue further | ||
|
@@ -583,7 +586,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) { | |
* d) the element is not a child of the $rootElement | ||
*/ | ||
function areAnimationsAllowed(element, parentElement, event) { | ||
var bodyElement = jqLite($document[0].body); | ||
var bodyElement = jqLite(rawDocument.body); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC there is one more access to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, in animateCssDriver.js. |
||
var bodyElementDetected = isMatchingElement(element, bodyElement) || element[0].nodeName === 'HTML'; | ||
var rootElementDetected = isMatchingElement(element, $rootElement); | ||
var parentAnimationDetected = false; | ||
|
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.
"... mocked out in tests ..."