Skip to content

Instantly share code, notes, and snippets.

@Mitscherlich
Created March 3, 2021 05:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mitscherlich/95706e4c900441fa549727af6388d08d to your computer and use it in GitHub Desktop.
Save Mitscherlich/95706e4c900441fa549727af6388d08d to your computer and use it in GitHub Desktop.
Simple Proxy Compatibility Test.html
<!DOCTYPE html>
<html>
<head>
<meta chaset="utf-8" />
<!-- bootstrap -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" />
</head>
<body>
<div class="container pt-4">
<div class="card">
<div class="card-header">Proxy Compatibility</div>
<div class="card-body">
<div class="alert alert-dark" id="compatibility">
<span class="col-3">Proxy</span>
<span class="col" id="result">Testing...</span>
</div>
</div>
</div>
</div>
<!-- Proxy polyfill -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/proxy-polyfill/proxy.min.js"></script>
<!-- jQuery -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.slim.min.js"></script>
<script type="text/javascript">
var utils = (function () {
var objProto = Object.prototype;
var toString = objProto.toString;
function isDef(value) {
return value !== void 0;
}
function isNative(Ctor) {
var tag = toString.call(Ctor);
return /[native code]/.test(tag);
}
return {
isDef: isDef,
isNative: isNative,
};
})();
</script>
<script type="text/javascript">
(function ($) {
var $compatibility = $('#compatibility');
var $result = $('#result');
var Proxy = window.Proxy;
$(function () {
if (!utils.isDef(Proxy)) {
$compatibility.removeClass('alert-dark');
$compatibility.addClass('alert-danger');
$result.empty().text('Failed!');
return;
}
if (!utils.isNative(Proxy)) {
$compatibility.removeClass('alert-dark');
$compatibility.addClass('alert-warn');
$result.empty().text('Polyfill.');
return;
}
$compatibility.removeClass('alert-dark');
$compatibility.addClass('alert-success');
$result.empty().text('Native.');
});
})(window.jQuery);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment