]> source.dussan.org Git - jquery.git/commitdiff
Offset: Send px-ed strings to .css()
authorDave Methvin <dave.methvin@gmail.com>
Mon, 21 Oct 2019 16:53:24 +0000 (12:53 -0400)
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Mon, 21 Oct 2019 16:53:24 +0000 (18:53 +0200)
An upcoming release of Migrate will generate warnings for calls to .css() that pass numbers rather than strings, see jquery/jquery-migrate#296 . At the moment, core's .offset() setter passes numbers rather than px strings so it would throw warnings. This commit fixes that.

Closes gh-4508

src/offset.js

index 6e973587062b47e09a5e5bcc58bf2e1988bad5a3..62166bc9999f37838abf3544aa62876cfcc25727 100644 (file)
@@ -63,6 +63,12 @@ jQuery.offset = {
                        options.using.call( elem, props );
 
                } else {
+                       if ( typeof props.top === "number" ) {
+                               props.top += "px";
+                       }
+                       if ( typeof props.left === "number" ) {
+                               props.left += "px";
+                       }
                        curElem.css( props );
                }
        }