Skip to content

Commit

Permalink
Make adjustments so that TypeIt works in IE.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmacarthur committed Mar 3, 2018
1 parent 126e92f commit 0683e0c
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 14 deletions.
18 changes: 14 additions & 4 deletions dist/typeit.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* typeit - The most versatile animated typing utility on the planet.
* Author: Alex MacArthur <alex@macarthur.me> (https://macarthur.me)
* Version: v5.5.1
* Version: v5.5.2
* URL: https://typeitjs.com
* License: GPL-2.0
*
Expand All @@ -26,6 +26,16 @@ window.TypeItDefaults = {
callback: function callback() {}
};

if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, "startsWith", {
value: function value(search) {
return this.indexOf(search) === 0;
},
configurable: true,
writable: true
});
}

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
Expand Down Expand Up @@ -196,7 +206,7 @@ var Instance = function () {

string = this.toArray(string);

var doc = document.implementation.createHTMLDocument();
var doc = document.implementation.createHTMLDocument("");
doc.body.innerHTML = string;

//-- If it's designated, rake that bad boy for HTML tags and stuff.
Expand All @@ -209,7 +219,7 @@ var Instance = function () {
if (this.options.html && string[0].startsWith("<") && !string[0].startsWith("</")) {
//-- Create node of that string name.
var matches = string[0].match(/\<(.*?)\>/);
var _doc = document.implementation.createHTMLDocument();
var _doc = document.implementation.createHTMLDocument("");
_doc.body.innerHTML = "<" + matches[1] + "></" + matches[1] + ">";

//-- Add to the queue.
Expand Down Expand Up @@ -354,7 +364,7 @@ var Instance = function () {
var _this2 = this;

//-- If any of the existing children nodes have .ti-container, clear it out because this is a remnant of a previous instance.
this.element.childNodes.forEach(function (node) {
[].slice.call(this.element.childNodes).forEach(function (node) {
if (node.classList === undefined) return;

if (node.classList.contains("ti-container")) {
Expand Down
18 changes: 14 additions & 4 deletions dist/typeit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* typeit - The most versatile animated typing utility on the planet.
* Author: Alex MacArthur <alex@macarthur.me> (https://macarthur.me)
* Version: v5.5.1
* Version: v5.5.2
* URL: https://typeitjs.com
* License: GPL-2.0
*
Expand Down Expand Up @@ -32,6 +32,16 @@ window.TypeItDefaults = {
callback: function callback() {}
};

if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, "startsWith", {
value: function value(search) {
return this.indexOf(search) === 0;
},
configurable: true,
writable: true
});
}

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
Expand Down Expand Up @@ -202,7 +212,7 @@ var Instance = function () {

string = this.toArray(string);

var doc = document.implementation.createHTMLDocument();
var doc = document.implementation.createHTMLDocument("");
doc.body.innerHTML = string;

//-- If it's designated, rake that bad boy for HTML tags and stuff.
Expand All @@ -215,7 +225,7 @@ var Instance = function () {
if (this.options.html && string[0].startsWith("<") && !string[0].startsWith("</")) {
//-- Create node of that string name.
var matches = string[0].match(/\<(.*?)\>/);
var _doc = document.implementation.createHTMLDocument();
var _doc = document.implementation.createHTMLDocument("");
_doc.body.innerHTML = "<" + matches[1] + "></" + matches[1] + ">";

//-- Add to the queue.
Expand Down Expand Up @@ -360,7 +370,7 @@ var Instance = function () {
var _this2 = this;

//-- If any of the existing children nodes have .ti-container, clear it out because this is a remnant of a previous instance.
this.element.childNodes.forEach(function (node) {
[].slice.call(this.element.childNodes).forEach(function (node) {
if (node.classList === undefined) return;

if (node.classList.contains("ti-container")) {
Expand Down
4 changes: 2 additions & 2 deletions dist/typeit.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typeit",
"version": "5.5.1",
"version": "5.5.2",
"description": "The most versatile animated typing utility on the planet.",
"author": "Alex MacArthur <alex@macarthur.me> (https://macarthur.me)",
"license": "GPL-2.0",
Expand Down
7 changes: 4 additions & 3 deletions src/instance.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "./defaults.js";
import "./startsWith";

export default class Instance {
constructor(element, id, options) {
Expand Down Expand Up @@ -117,7 +118,7 @@ export default class Instance {

string = this.toArray(string);

var doc = document.implementation.createHTMLDocument();
var doc = document.implementation.createHTMLDocument("");
doc.body.innerHTML = string;

//-- If it's designated, rake that bad boy for HTML tags and stuff.
Expand All @@ -133,7 +134,7 @@ export default class Instance {
) {
//-- Create node of that string name.
let matches = string[0].match(/\<(.*?)\>/);
let doc = document.implementation.createHTMLDocument();
let doc = document.implementation.createHTMLDocument("");
doc.body.innerHTML = "<" + matches[1] + "></" + matches[1] + ">";

//-- Add to the queue.
Expand Down Expand Up @@ -292,7 +293,7 @@ export default class Instance {
*/
checkElement() {
//-- If any of the existing children nodes have .ti-container, clear it out because this is a remnant of a previous instance.
this.element.childNodes.forEach(node => {
[].slice.call(this.element.childNodes).forEach(node => {
if (node.classList === undefined) return;

if (node.classList.contains("ti-container")) {
Expand Down
9 changes: 9 additions & 0 deletions src/startsWith.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, "startsWith", {
value: function(search) {
return this.indexOf(search) === 0;
},
configurable: true,
writable: true
});
}

0 comments on commit 0683e0c

Please sign in to comment.