Skip to content

Instantly share code, notes, and snippets.

@richardkazuomiller
Last active August 29, 2015 14:27
Show Gist options
  • Save richardkazuomiller/18ee3ca7275ddeb17dac to your computer and use it in GitHub Desktop.
Save richardkazuomiller/18ee3ca7275ddeb17dac to your computer and use it in GitHub Desktop.
Weird hack to get embedded tweets to load on (some versions of) iOS
<script src="/bower_components/webcomponentsjs/webcomponents.js"></script>
<!-- added the following script after importing webcomponents.js because Twitter
widgets call matches.apply(<something other than an element>) . Without it
the error "Can only call Element.matches on instances of Element" when trying
to embed a tweet on iOS Safari.
-->
<script>
Element.prototype._matches = Element.prototype.matches
Element.prototype.matches = function(element){
if(!(this instanceof Element)){
console.log(this)
console.log(arguments)
return false;
}
return this._matches.apply(this,arguments)
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment