You see the Javascript/Typescript and try yourself the code here.
or have/copy the class in the index.ts file or in the section Typescript Class.
When looking for a solution to use the include Javascript function, I notice that IE didn't had support and I lost a lot of time looking
for a solution in the internet.
For this reason, I did a script that is already converted to Javascript here that enables the use of include by calling a class and giving what values you want to compare and the value to compare.
This class enables the use of include Javascript function in IE.
class ITM {
private containing: any;
private browser: boolean = false;
constructor() {
//code goes here
}
/**
* [browserDetect - This method is to know when the user is using Internet Explorer]
*/
private browserDetect() {
if ((navigator.userAgent.indexOf('Trident/7.0') > 0) ||
(/MSIE 10/i.test(navigator.userAgent)) ||
(/MSIE 9/i.test(navigator.userAgent) ||
/rv:11.0/i.test(navigator.userAgent))) {
this.browser = true;
}
}
/**
* [includesToMatch - Depending on the browser, this method compares your variables using the include or the match Javascript function,
* enabling it to work with the last breakthrough tecnologies of ES]
*/
public includesToMatch(variableToCompare: string, containing: Array<string>) {
let variableToMatch: string;
this.browserDetect()
this.containing = containing;
if (this.browser) {
for (let i = 0; i < containing.length; i++) {
if (variableToCompare.match(containing[i])) {
return true;
}
}
} else {
if (this.containing.includes(variableToCompare)) {
return true;
}
}
return false;
}
}import {ITM} from '../your-folder/your-file';
const test = new ITM();
test.includesToMatch(variabletoCompare, arrayToCompare);- Fork this project: https://github.com/Mteixeira88/css-variables-IE-script
- Create your feature branch:
git checkout -b my-new-feature - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin my-new-feature - Submit a pull request
Miguel Teixeira
This is free and unencumbered software released into the public domain. For more information, please refer to http://unlicense.org.