boolean isGuarded ( T resource ) { // Check if this polyfill is already guarded. If so, return true right away. if ( guarded . contains ( resource ) ) { return true ; } // If not, see if this is itself a feature check guard. This is // defined as a usage of the polyfill in such a way that throws // away the actual value and only cares about its truthiness or // typeof. We walk up the ancestor tree through a small set of // node types and if this is detected to be a guard, then the // conditional node is marked as a guard for this polyfill. Context context = contextStack . peek ( ) ; if ( ! context . safe ) { return false ; } // Loop over all the linked conditionals and register this as a guard. while ( context != null && context . conditional != null ) { registeredGuards . put ( context . conditional , resource ) ; context = context . linked ; } return true ; }
Determines if the given resource is guarded either intrinsically or conditionally . If the former any ancestor conditional nodes are registered as feature - testing the resource .