Use current document to process <script> tags (fixes ajaxorg/ace#2003)

Use current document not the main document for checking other `<script>` tags.

Should fix loading `ace.js` from HTML Imported documents.

PS> How should I deliver signed CLA?
could you please add a comment here that this is needed for html imports.