mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-30 12:38:48 +01:00
Add polyfills for String.trimLeft/Right for browsers without support.
This commit is contained in:
parent
dce6024e16
commit
85531ff21e
4 changed files with 57 additions and 1 deletions
26
demo/browser-polyfills.js
Normal file
26
demo/browser-polyfills.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
"use strict";
|
||||
|
||||
// Polyfills for browsers that do not support String.trimLeft/Right
|
||||
function trimLeftPolyfill() {
|
||||
return this.replace(/^\s*/, "");
|
||||
}
|
||||
/* istanbul ignore if */
|
||||
if (!String.prototype.trimLeft) {
|
||||
String.prototype.trimLeft = trimLeftPolyfill;
|
||||
}
|
||||
function trimRightPolyfill() {
|
||||
return this.replace(/\s*$/, "");
|
||||
}
|
||||
/* istanbul ignore if */
|
||||
if (!String.prototype.trimRight) {
|
||||
String.prototype.trimRight = trimRightPolyfill;
|
||||
}
|
||||
|
||||
// Export for testing
|
||||
/* istanbul ignore else */
|
||||
if ((typeof module !== "undefined") && module.exports) {
|
||||
module.exports = {
|
||||
"trimLeftPolyfill": trimLeftPolyfill,
|
||||
"trimRightPolyfill": trimRightPolyfill
|
||||
};
|
||||
}
|
||||
|
|
@ -27,6 +27,7 @@
|
|||
<footer>Copyright © 2015 by <a href="//dlaa.me/">David Anson</a></footer>
|
||||
</div>
|
||||
</div>
|
||||
<script src="browser-polyfills.js"></script>
|
||||
<script src="../node_modules/markdown-it/dist/markdown-it.min.js"></script>
|
||||
<script src="require-stub.js"></script>
|
||||
<script src="markdownlint-browser.js"></script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue