Skip to content

Commit 169ea70

Browse files
committed
Fix tabs js on browsers without String.startsWith (#33)
1 parent a7213e0 commit 169ea70

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sphinx_tabs/tabs.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
if (!String.prototype.startsWith) {
2+
Object.defineProperty(String.prototype, 'startsWith', {
3+
value: function(search, pos) {
4+
pos = !pos || pos < 0 ? 0 : +pos;
5+
return this.substring(pos, pos + search.length) === search;
6+
}
7+
});
8+
}
9+
110
// From http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport
211
function elementIsInView (el) {
312
if (typeof jQuery === "function" && el instanceof jQuery) {

0 commit comments

Comments
 (0)