Proposal to fix trac #17155

This patch is based on rawld proposal, enhanced to fix the bug also in the case of a fallback from "aa-bb" to "aa".
 * See https://bugs.dojotoolkit.org/ticket/17155 for more details.