addGetHookIf.js 590 B

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