Once one is inside $(...), quoting starts all over from scratch.
In other words, "..." and $(...) can nest within each other. Process Command substitution, $(...), can contain one or more complete double-quoted strings. Also, double-quoted strings may contain one or more complete processcommand substitutions. But, they do not interlace. Thus, a double-quoted string that starts inside a processcommand substitution will never extend outside of it or vice versa.
So, consider:
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
Inside the inner $(...) is:
dirname "${BASH_SOURCE[0]}"
In the above ${BASH_SOURCE[0]} is double-quoted. Any quotes, double or single, outside of the $(...) are irrelevant when determining that ${BASH_SOURCE[0]} is double-quoted.
The outer $(...) contains:
cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd
Here, the expression $( dirname "${BASH_SOURCE[0]}" ) is double-quoted. The fact that there are quotes outside of the outer $(...) is irrelevant when considering what is inside it. The fact that there are quotes inside the inner $(...) is also irrelevant.
