It's not that simple because the user's devicePixelRatio might be fractional. Say it's 1.5, then scaling up, some low-res pixels get scaled up to N pixels and other to N+1 and you can get something really ugly, especially if the thing you're scaling is a stippled pattern.
Well, I consider that still vastly better for pixel art than it being blurry. If you really want to handle 1.5x resolutions you can scale the image to that resolution yourself in the way you think is best and provide it using srcset.