MCPcopy Create free account
hub / github.com/JsAaron/jQuery / addGetHookIf

Function addGetHookIf

2.1.1/src/css/addGetHookIf.js:3–18  ·  view source on GitHub ↗
( conditionFn, hookFn )

Source from the content-addressed store, hash-verified

1define(function() {
2
3function addGetHookIf( conditionFn, hookFn ) {
4 // Define the hook, we'll check on the first run if it's really needed.
5 return {
6 get: function() {
7 if ( conditionFn() ) {
8 // Hook not needed (or it's not possible to use it due
9 // to missing dependency), remove it.
10 delete this.get;
11 return;
12 }
13
14 // Hook needed; redefine it so that the support test is not executed again.
15 return (this.get = hookFn).apply( this, arguments );
16 }
17 };
18}
19
20return addGetHookIf;
21

Callers 2

offset.jsFile · 0.50
css.jsFile · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected