In Bourne/POSIX shells, the special parameter $0 is set to the name of the script that the shell executes (or the name of the shell itself). It does not change when reading another script file with the . (“dot”) command. Bash follows the standard behavior in this respect, including when using the source synonym of . (“dot”).
In zsh, by default the special parameter $0 is set to the path to the current script or the name of the current function, i.e. it changes when using the . or source builtin, when calling a function, and when returning from a function or script. You can change zsh to the standard behavior by settingunsetting the option function_argzero (which is set whenby default unless zsh is in sh or ksh emulation mode) or setting posix_argzero.
In bash, the path to the current script (affected by . or source) is available under the name $BASH_ARGV0.
Incidentally, since you know that you have a path to a non-directory file with a directory component, you can use the simple and slightly faster "${0%/*}" to refer to the directory containing it.1
1 It's also more robust than "$(dirname -- "$0")" because it works if the directory name ends with a newline, and than "$(dirname "$0")" because it works if the path starts with a dash, but neither of those apply here. It's more fragile because it doesn't work if the path ends with a slash or doesn't contain a slash at all, but that doesn't apply here either.