Skip to content

Instantly share code, notes, and snippets.

@tcyrus
Created January 6, 2017 15:49
Show Gist options
  • Select an option

  • Save tcyrus/ca82f9aff4478ad8ddaa914241a0eeef to your computer and use it in GitHub Desktop.

Select an option

Save tcyrus/ca82f9aff4478ad8ddaa914241a0eeef to your computer and use it in GitHub Desktop.
if (!Element.prototype.getElementByTagName) {
Element.prototype.getElementByTagName = function(selector) {
return this.getElementsByTagName(selector).item(0);
}
}
if (!HTMLDocument.prototype.getElementByTagName) {
HTMLDocument.prototype.getElementByTagName = function(selector) {
return this.getElementsByTagName(selector).item(0);
}
}
if (!Element.prototype.getElementByClassName) {
Element.prototype.getElementByClassName = function(selector) {
return this.getElementsByClassName(selector).item(0);
}
}
if (!HTMLDocument.prototype.getElementByClassName) {
HTMLDocument.prototype.getElementByClassName = function(selector) {
return this.getElementsByClassName(selector).item(0);
}
}
if (!HTMLDocument.prototype.getElementByName) {
HTMLDocument.prototype.getElementByName = function(selector) {
return this.getElementsByName(selector).item(0);
}
}
if (!Element.prototype.getElementByTagName) {
Element.prototype.getElementByTagName = function(selector) {
return this.getElementsByTagName(selector).item(0);
}
}
if (!HTMLDocument.prototype.getElementByTagName) {
HTMLDocument.prototype.getElementByTagName = function(selector) {
return this.getElementsByTagName(selector).item(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment