The canvas specification places no restriction on width or height being negative, so if they were negative the rectangle would draw in the opposite direction.
The SVG specification says that if width or height are negative then the rectangle is not drawn.
If you want to implement this in SVG you'll have to make sure the rectangles width/height are always positive and calculate the x/y accordingly.