JSFiddle - React, Tailwind, and code Playground
JavaScript
(function( $ ){
var rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
rreadonlyheaders = /(accept-(charset|encoding)|content-length|(content-)?transfer-encoding|cookie2?|date|expect|host|keep-alive|referer|te|trailer|upgrade|user-agent|via)/ig,
rbeforesendreadonly = /setrequestheader\([\"'](accept-(charset|encoding)|content-length|(content-)?transfer-encoding|cookie2?|date|expect|host|keep-alive|referer|te|trailer|upgrade|user-agent|via)/ig,
ajaxFunc, header;
$.each( 'attr removeAttr'.split(' '), function( i, val ) {
var realFunc = $.fn[ val ];
$.fn[ val ] = function( name ) {
if ( rboolean.test(name) ) {
// How should we warn people using browsers that don't implement console && console.warn ( I'm looking at you IE7- ).
// Swallow the errors, do an alert, or should we create some kind of floating warn box on the page since this is a *debug* script?
console.warn( 'You should be using jQuery.fn.prop to set boolean property: ' + name );
}
return realFunc.apply( this, Array.prototype.slice.call(arguments, 0) );
};
});
ajaxFunc = $.ajax;
$.ajax = function( url, settings ) {
if ( !settings && $.isPlainObject(url) ) {
settings = url;
}
if ( settings ) {
if ( settings.headers ) {
for ( header in settings.headers ) {
if ( rreadonlyheaders.test(header) ) {
console.warn( 'Attempting to set readonly XHR header: ' + header );
}
}
}
// SetRequestHeader isn't exposed here, so the best thing I can think of to do is check the actual function definition
if ( settings.beforeSend ) {
while ( (header =...