UPDATE 4.4.0.0
[phpmyadmin.git] / js / jquery / src / jquery / css / addGetHookIf.js
blob7efcbc860eaec46cf3295cbc7422a16d9cecf79c
1 define(function() {
3 function 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                         var condition = conditionFn();
9                         if ( condition == null ) {
10                                 // The test was not ready at this point; screw the hook this time
11                                 // but check again when needed next time.
12                                 return;
13                         }
15                         if ( condition ) {
16                                 // Hook not needed (or it's not possible to use it due to missing dependency),
17                                 // remove it.
18                                 // Since there are no other hooks for marginRight, remove the whole object.
19                                 delete this.get;
20                                 return;
21                         }
23                         // Hook needed; redefine it so that the support test is not executed again.
25                         return (this.get = hookFn).apply( this, arguments );
26                 }
27         };
30 return addGetHookIf;
32 });