Added fix for #986 (ID selector within an element that doesn't exist).