Ensure id attributes on elements only affect elements present in a docum...

...ent.