Skip to content

Instantly share code, notes, and snippets.

@pier-oliviert
Last active August 29, 2015 14:13
Show Gist options
  • Select an option

  • Save pier-oliviert/ae0320dce453b414309e to your computer and use it in GitHub Desktop.

Select an option

Save pier-oliviert/ae0320dce453b414309e to your computer and use it in GitHub Desktop.
var div = document.createElement('div')
div.innerHTML = "<script></script>"
var s = div.children[0]
s.src = "//connect.facebook.net/en_US/all.js#xfbml=1"
// true
s instanceof HTMLScriptElement
// Will NOT load the script
document.head.appendChild(s)
var s = document.createElement('script')
s.src = "//connect.facebook.net/en_US/all.js#xfbml=1"
// true
s instanceof HTMLScriptElement
// Will load the script
document.head.appendChild(s)
@davidwebca
Copy link

Just tested. It's not because it's a sub-node, really just because it's created with innerHTML. I guess you can file that as a bug somewhere, but maybe there's an underlying explanation. Curious to know.

@pier-oliviert
Copy link
Author

@david-treblig you are right I don't think it's a webkit bug either (tested on FF & safari too and I actually made that distinction when I submitted the bug over to chromium.)

I also think that the node is internally marked differently. I really think this is unintended behavior, but as my bug report are usually dismissed, I wouldn't be surprised if they dismiss it.

@pier-oliviert
Copy link
Author

@pier-oliviert
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment