Fix a script eval bug

Do not eval the script if script is append to the element which is not contained by document.
View test for details.