1. libj-polyfills
Adds some polyfills to browser.
libj-polyfills
Package: libj-polyfills
Last modified: Sat, 07 May 2022 23:08:05 GMT
Version: 1.0.4
License: ISC
Downloads: 9

Install

npm install libj-polyfills
yarn add libj-polyfills

libj-polyfills

Part of libj tools

Adds some polyfills to browser.

Needs jQuery

Adds the following for specific browser bugs:

  • classList for IE10 & IE11 See this
  • viewport fix for IE10 See this
  • maxlength attribute bug in many browsers

Adds these to window global variable for logging:

  • log function is a replacement for console.log and can be used globally. Usage:
log('test')   //prints test in console
  • stackTrace function is added globally to show current stack trace. Usage:
stackTrace()  //returns a string containing current stack trace
  • logStackTrace function is added globally to print stackTrace output to console. Usage:
logStackTrace() //prints current stack trace in console

Adds these to polyfill jquery in older browsers (Safari, IE):

  • $.fn.classes
  • $.fn.hasAttr checks if a jquery element contains an attribute. Calls $.fn.attr internally. Usage:
$('#someElementId').hasAttr('custom-attribute')
  • $.fn.equals checks if a given element equals another element. Usage:
$('#el1').equals($('#el1))    //returns true
  • $.fn.outerHTML returns outer html of the calling element. Usage:
<div id="el1">iii</div>
$('#el1').outerHTML()    //returns <div id="el1">iii</div>

Adds these to String prototype in borwsers:

  • format: Usage:
String.format("Hello %0. Welcome to %1", "Saeid", "libj")  //returns "Hello Saeid. Welcome to libj"

Adds these to Number prototype in browsers:

padZero`: Inserts specified number of zeros at the beginning of the calling number. Usage:

var x = 12;
x.padZero(4);    //returns "0012"

Usage (npm)

npm install libj-polyfills

Add this to top of your entry point:

import 'libj-polyfills'

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin