Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | define( function() { |
| 2 | |
| 3 | "use strict"; |
| 4 | |
| 5 | // A method for quickly swapping in/out CSS properties to get correct calculations. |
Renovate bot | f591dcf | 2023-12-30 14:13:54 +0000 | [diff] [blame] | 6 | return function( elem, options, callback ) { |
Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 7 | var ret, name, |
| 8 | old = {}; |
| 9 | |
| 10 | // Remember the old values, and insert the new ones |
| 11 | for ( name in options ) { |
| 12 | old[ name ] = elem.style[ name ]; |
| 13 | elem.style[ name ] = options[ name ]; |
| 14 | } |
| 15 | |
Renovate bot | f591dcf | 2023-12-30 14:13:54 +0000 | [diff] [blame] | 16 | ret = callback.call( elem ); |
Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 17 | |
| 18 | // Revert the old values |
| 19 | for ( name in options ) { |
| 20 | elem.style[ name ] = old[ name ]; |
| 21 | } |
| 22 | |
| 23 | return ret; |
| 24 | }; |
| 25 | |
| 26 | } ); |