Created
April 23, 2018 15:07
-
-
Save anselmbradford/d02263ae3d917d5b7c245b98f6cf8f72 to your computer and use it in GitHub Desktop.
fastdom-strict without throwing errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is https://github.com/wilsonpage/fastdom/blob/master/src/fastdom-strict.js | |
// run through webpack, with the errors wrapped in try…catch blocks to output them all for a page. | |
! function(t) { | |
var e = {}; | |
function n(r) { | |
if (e[r]) return e[r].exports; | |
var i = e[r] = { | |
i: r, | |
l: !1, | |
exports: {} | |
}; | |
return t[r].call(i.exports, i, i.exports, n), i.l = !0, i.exports | |
} | |
n.m = t, n.c = e, n.d = function(t, e, r) { | |
n.o(t, e) || Object.defineProperty(t, e, { | |
configurable: !1, | |
enumerable: !0, | |
get: r | |
}) | |
}, n.r = function(t) { | |
Object.defineProperty(t, "__esModule", { | |
value: !0 | |
}) | |
}, n.n = function(t) { | |
var e = t && t.__esModule ? function() { | |
return t.default | |
} : function() { | |
return t | |
}; | |
return n.d(e, "a", e), e | |
}, n.o = function(t, e) { | |
return Object.prototype.hasOwnProperty.call(t, e) | |
}, n.p = "", n(n.s = 85) | |
}({ | |
11: function(t, e, n) { | |
var r; | |
function i(t) { | |
return (i = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) { | |
return typeof t | |
} : function(t) { | |
return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t | |
})(t) | |
}! function(e) { | |
"use strict"; | |
var o = function() {}, | |
s = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.msRequestAnimationFrame || function(t) { | |
return setTimeout(t, 16) | |
}; | |
function a() { | |
this.reads = [], this.writes = [], this.raf = s.bind(e), o("initialized", this) | |
} | |
function u(t) { | |
t.scheduled || (t.scheduled = !0, t.raf(function(t) { | |
o("flush"); | |
var e, n = t.writes, | |
r = t.reads; | |
try { | |
o("flushing reads", r.length), c(r), o("flushing writes", n.length), c(n) | |
} catch (t) { | |
e = t | |
} | |
if (t.scheduled = !1, (r.length || n.length) && u(t), e) { | |
try { | |
if (o("task errored", e.message), !t.catch) throw e; | |
} catch( e ) { | |
console.log( e ); | |
} | |
t.catch(e) | |
} | |
}.bind(null, t)), o("flush scheduled")) | |
} | |
function c(t) { | |
var e; | |
for (o("run tasks"); e = t.shift();) e() | |
} | |
function p(t, e) { | |
var n = t.indexOf(e); | |
return !!~n && !!t.splice(n, 1) | |
} | |
a.prototype = { | |
constructor: a, | |
measure: function(t, e) { | |
o("measure"); | |
var n = e ? t.bind(e) : t; | |
return this.reads.push(n), u(this), n | |
}, | |
mutate: function(t, e) { | |
o("mutate"); | |
var n = e ? t.bind(e) : t; | |
return this.writes.push(n), u(this), n | |
}, | |
clear: function(t) { | |
return o("clear", t), p(this.reads, t) || p(this.writes, t) | |
}, | |
extend: function(t) { | |
try { | |
if (o("extend", t), "object" != i(t)) throw new Error("expected object"); | |
} catch( e ) { | |
console.log( e ); | |
} | |
var e = Object.create(this); | |
return function(t, e) { | |
for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]) | |
}(e, t), e.fastdom = this, e.initialize && e.initialize(), e | |
}, | |
catch: null | |
}; | |
var f = e.fastdom = e.fastdom || new a; | |
void 0 === (r = function() { | |
return f | |
}.call(f, n, f, t)) || (t.exports = r) | |
}("undefined" != typeof window ? window : this) | |
}, | |
5: function(t, e) { | |
t.exports = function(t) { | |
return t.webpackPolyfill || (t.deprecate = function() {}, t.paths = [], t.children || (t.children = []), Object.defineProperty(t, "loaded", { | |
enumerable: !0, | |
get: function() { | |
return t.l | |
} | |
}), Object.defineProperty(t, "id", { | |
enumerable: !0, | |
get: function() { | |
return t.i | |
} | |
}), t.webpackPolyfill = 1), t | |
} | |
}, | |
81: function(t, e) { | |
t.exports = function() { | |
try { | |
throw new Error("define cannot be used indirect") | |
} catch( e ) { | |
console.log( e ); | |
} | |
} | |
}, | |
82: function(t, e, n) { | |
(function(t) { | |
var e; | |
function r(t) { | |
return (r = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) { | |
return typeof t | |
} : function(t) { | |
return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t | |
})(t) | |
}! function() { | |
"use strict"; | |
var i = function() {}, | |
o = { | |
prototype: { | |
Document: { | |
execCommand: c, | |
elementFromPoint: u, | |
elementsFromPoint: u, | |
scrollingElement: u | |
}, | |
Node: { | |
appendChild: { | |
type: c, | |
test: function(t, e, n) { | |
try { | |
if ((g(e) || g(n[0])) && t.not("mutate")) throw m(3, this.name) | |
} catch( e ) { | |
console.log( e ); | |
} | |
} | |
}, | |
insertBefore: { | |
type: c, | |
test: function(t, e, n) { | |
try { | |
if ((g(e) || g(n[0])) && t.not("mutate")) throw m(3, this.name) | |
} catch( e ) { | |
console.log( e ); | |
} | |
} | |
}, | |
removeChild: { | |
type: c, | |
test: function(t, e, n) { | |
try { | |
if ((g(e) || g(n[0])) && t.not("mutate")) throw m(3, this.name) | |
} catch( e ) { | |
console.log( e ); | |
} | |
} | |
}, | |
textContent: c | |
}, | |
Element: { | |
scrollIntoView: c, | |
scrollBy: c, | |
scrollTo: c, | |
getClientRects: u, | |
getBoundingClientRect: u, | |
clientLeft: u, | |
clientWidth: u, | |
clientHeight: u, | |
scrollLeft: p, | |
scrollTop: p, | |
scrollWidth: u, | |
scrollHeight: u, | |
innerHTML: c, | |
outerHTML: c, | |
insertAdjacentHTML: c, | |
remove: c, | |
setAttribute: c, | |
removeAttribute: c, | |
className: c, | |
classList: l | |
}, | |
HTMLElement: { | |
offsetLeft: u, | |
offsetTop: u, | |
offsetWidth: u, | |
offsetHeight: u, | |
offsetParent: u, | |
innerText: p, | |
outerText: p, | |
focus: u, | |
blur: u, | |
style: f | |
}, | |
CharacterData: { | |
remove: c, | |
data: c | |
}, | |
Range: { | |
getClientRects: u, | |
getBoundingClientRect: u | |
}, | |
MouseEvent: { | |
layerX: u, | |
layerY: u, | |
offsetX: u, | |
offsetY: u | |
}, | |
HTMLButtonElement: { | |
reportValidity: u | |
}, | |
HTMLDialogElement: { | |
showModal: c | |
}, | |
HTMLFieldSetElement: { | |
reportValidity: u | |
}, | |
HTMLImageElement: { | |
width: p, | |
height: p, | |
x: u, | |
y: u | |
}, | |
HTMLInputElement: { | |
reportValidity: u | |
}, | |
HTMLKeygenElement: { | |
reportValidity: u | |
}, | |
SVGSVGElement: { | |
currentScale: p | |
} | |
}, | |
instance: { | |
window: { | |
getComputedStyle: { | |
type: u, | |
test: function(t, e, n) { | |
try { | |
if (g(n[0]) && t.not("measure")) throw m(2, "getComputedStyle") | |
} catch( e ) { | |
console.log( e ); | |
} | |
} | |
}, | |
scrollBy: c, | |
scrollTo: c, | |
scroll: c | |
} | |
} | |
}; | |
function s(t) { | |
this.properties = [], this._phase = null, this.win = t, this.createPrototypeProperties(), this.createInstanceProperties() | |
} | |
function a(t, e, n, o) { | |
i("Property", e, n), this.strictdom = o, this.object = t, this.name = e; | |
var s = this.getDescriptor(); | |
"object" == r(n) && Object.assign(this, n), this.descriptors = { | |
unwrapped: s, | |
wrapped: this.wrap(s) | |
} | |
} | |
function u() { | |
a.apply(this, arguments) | |
} | |
function c() { | |
a.apply(this, arguments) | |
} | |
function p() { | |
a.apply(this, arguments) | |
} | |
function f() { | |
a.apply(this, arguments) | |
} | |
function l() { | |
a.apply(this, arguments) | |
} | |
function h(t, e) { | |
this.strictdom = e, this.el = t | |
} | |
function d(t, e) { | |
this.strictdom = e, this.el = t | |
} | |
function m(t) { | |
return new Error({ | |
1: "Can only set " + arguments[1] + " during 'mutate' phase", | |
2: "Can only get " + arguments[1] + " during 'measure' phase", | |
3: "Can only call `." + arguments[1] + "()` during 'mutate' phase", | |
4: "Invalid phase: " + arguments[1] | |
}[t]) | |
} | |
function y(t, e) { | |
return Object.getOwnPropertyDescriptor(t, e) | |
} | |
function w(t, e) { | |
return Object.assign(Object.create(t.prototype), e) | |
} | |
function g(t) { | |
return t === window || document.contains(t) | |
} | |
s.prototype = { | |
phase: function(t, e) { | |
if (!arguments.length) return this._phase; | |
try { | |
if (!this.knownPhase(t)) throw m(4, t); | |
} catch( e ) { | |
console.log( e ); | |
} | |
var n = this._phase; | |
if (this._phase = t, "function" == typeof e) { | |
var r = e(); | |
return this._phase = n, r | |
} | |
}, | |
knownPhase: function(t) { | |
return !!~["measure", "mutate", null].indexOf(t) | |
}, | |
is: function(t) { | |
return this._phase === t | |
}, | |
not: function(t) { | |
return !this.is(t) | |
}, | |
enable: function() { | |
if (!this.enabled) { | |
i("enable"); | |
for (var t = this.properties.length; t--;) this.properties[t].enable(); | |
this.enabled = !0 | |
} | |
}, | |
disable: function() { | |
if (this.enabled) { | |
i("disable"); | |
for (var t = this.properties.length; t--;) this.properties[t].disable(); | |
this.enabled = !1, this.phase(null) | |
} | |
}, | |
createPrototypeProperties: function() { | |
i("create prototype properties"); | |
var t = o.prototype; | |
for (var e in t) | |
for (var n in t[e]) { | |
var r = this.win[e] && this.win[e].prototype; | |
r && r.hasOwnProperty(n) && this.properties.push(this.create(r, n, t[e][n])) | |
} | |
}, | |
createInstanceProperties: function() { | |
i("create instance properties"); | |
var t = o.instance; | |
for (var e in t) | |
for (var n in t[e]) { | |
var r = this.win[e]; | |
r && r.hasOwnProperty(n) && this.properties.push(this.create(r, n, t[e][n])) | |
} | |
}, | |
create: function(t, e, n) { | |
return i("create", e), new(n.type || n)(t, e, n, this) | |
} | |
}, a.prototype = { | |
getDescriptor: function() { | |
return i("get descriptor", this.name), Object.getOwnPropertyDescriptor(this.object, this.name) | |
}, | |
enable: function() { | |
i("enable", this.name), Object.defineProperty(this.object, this.name, this.descriptors.wrapped) | |
}, | |
disable: function() { | |
i("disable", this.name), Object.defineProperty(this.object, this.name, this.descriptors.unwrapped) | |
}, | |
wrap: function() {} | |
}, u.prototype = w(a, { | |
wrap: function(t) { | |
i("wrap measure", this.name); | |
var e = Object.assign({}, t), | |
n = t.value, | |
r = t.get, | |
o = this; | |
return "function" == typeof n ? e.value = function() { | |
return i("measure", o.name), o.test(o.strictdom, this, arguments), n.apply(this, arguments) | |
} : r && (e.get = function() { | |
return i("measure", o.name), o.test(o.strictdom, this, arguments), r.apply(this, arguments) | |
}), e | |
}, | |
test: function(t, e) { | |
try { | |
if (g(e || window) && t.not("measure")) throw m(2, this.name) | |
} catch( e ) { | |
console.log( e ); | |
} | |
} | |
}), c.prototype = w(a, { | |
wrap: function(t) { | |
i("wrap mutate", this.name); | |
var e = Object.assign({}, t), | |
n = t.value, | |
r = this; | |
return "function" == typeof n ? e.value = function() { | |
return r.test(r.strictdom, this, arguments), n.apply(this, arguments) | |
} : t.set && (e.set = function() { | |
return r.test(r.strictdom, this, arguments), t.set.apply(this, arguments) | |
}), e | |
}, | |
test: function(t, e) { | |
try { | |
if (g(e || window) && t.not("mutate")) throw m(3, this.name) | |
} catch( e ) { | |
console.log( e ); | |
} | |
} | |
}), p.prototype = w(a, { | |
wrap: function(t) { | |
i("wrap accessor", this.name); | |
var e = Object.assign({}, t), | |
n = t.get, | |
r = t.set, | |
o = this; | |
return n && (e.get = function() { | |
return o.testRead(o.strictdom, this, arguments), n.apply(this, arguments) | |
}), t.set && (e.set = function() { | |
return o.testWrite(o.strictdom, this, arguments), r.apply(this, arguments) | |
}), e | |
}, | |
testRead: u.prototype.test, | |
testWrite: c.prototype.test | |
}), w(a, { | |
getDescriptor: function() { | |
return {} | |
}, | |
disable: function() { | |
delete this.object[this.name] | |
}, | |
wrap: function(t) { | |
i("wrap value"); | |
var e = this.name, | |
n = this; | |
return t.get = function() { | |
i("get value", e), n.test(n.strictdom, this, arguments), n.disable(); | |
var t = this[e]; | |
return n.enable(), t | |
}, t | |
}, | |
test: u.prototype.test | |
}), f.prototype = w(a, { | |
wrap: function(t) { | |
i("wrap style"); | |
var e = this.strictdom, | |
n = Object.assign({}, t); | |
return n.get = function() { | |
return new h(this, e) | |
}, n | |
} | |
}), l.prototype = w(a, { | |
wrap: function(t) { | |
i("wrap style"); | |
var e = this.strictdom, | |
n = Object.assign({}, t); | |
return n.get = function() { | |
return new d(this, e) | |
}, n | |
} | |
}), h.prototype = { | |
_getter: y(HTMLElement.prototype, "style").get, | |
_get: function() { | |
return this._getter.call(this.el) | |
}, | |
setProperty: function(t, e) { | |
try { | |
if (g(this.el) && this.strictdom.not("mutate")) throw m(1, "style." + t); | |
} catch( e ) { | |
console.log( e ); | |
} | |
return this._get()[t] = e | |
}, | |
removeProperty: function(t) { | |
try { | |
if (g(this.el) && this.strictdom.not("mutate")) throw m(1, "style." + t); | |
} catch( e ) { | |
console.log( e ); | |
} | |
return this._get().removeProperty(t) | |
} | |
}, | |
function() { | |
var t = document.createElement("div").style; | |
for (var e in t) "" === t[e] && Object.defineProperty(h.prototype, e, { | |
get: n(e), | |
set: r(e) | |
}); | |
function n(t) { | |
return function() { | |
return this._get()[t] | |
} | |
} | |
function r(t) { | |
return function(e) { | |
try { | |
if (g(this.el) && this.strictdom.not("mutate")) throw m(1, "style." + t); | |
} catch( e ) { | |
console.log( e ); | |
} | |
return this.setProperty(t, e) | |
} | |
}["item", "getPropertyValue", "getPropertyCSSValue", "getPropertyPriority"].forEach(function(t) { | |
var e; | |
h.prototype[t] = (e = t, function() { | |
var t = this._get(); | |
return t[e].apply(t, arguments) | |
}) | |
}) | |
}(), d.prototype = { | |
_getter: y(Element.prototype, "classList").get, | |
_get: function() { | |
return this._getter.call(this.el) | |
}, | |
add: function(t) { | |
try { | |
if (g(this.el) && this.strictdom.not("mutate")) throw m(1, "class names"); | |
} catch( e ) { | |
console.log( e ); | |
} | |
this._get().add(t) | |
}, | |
contains: function(t) { | |
return this._get().contains(t) | |
}, | |
remove: function(t) { | |
try { | |
if (g(this.el) && this.strictdom.not("mutate")) throw m(1, "class names"); | |
} catch( e ) { | |
console.log( e ); | |
} | |
this._get().remove(t) | |
}, | |
toggle: function() { | |
try { | |
if (g(this.el) && this.strictdom.not("mutate")) throw m(1, "class names"); | |
} catch( e ) { | |
console.log( e ); | |
} | |
var t = this._get(); | |
return t.toggle.apply(t, arguments) | |
} | |
}; | |
var b = window.strictdom = window.strictdom || new s(window); | |
"f" == r(n(81))[0] ? void 0 === (e = function() { | |
return b | |
}.call(b, n, b, t)) || (t.exports = e) : "o" == r(t)[0] && (t.exports = b) | |
}() | |
}).call(this, n(5)(t)) | |
}, | |
83: function(t, e, n) { | |
"use strict"; | |
var r = n(82), | |
i = n(11), | |
o = !1; | |
window.fastdom = t.exports = i.extend({ | |
measure: function(t, e) { | |
var n = e ? t.bind(e) : t; | |
return this.fastdom.measure(function() { | |
return o ? r.phase("measure", n) : n() | |
}, e) | |
}, | |
mutate: function(t, e) { | |
var n = e ? t.bind(e) : t; | |
return this.fastdom.mutate(function() { | |
return o ? r.phase("mutate", n) : n() | |
}, e) | |
}, | |
strict: function(t) { | |
t ? (o = !0, r.enable()) : (o = !1, r.disable()) | |
} | |
}), window.fastdom.strict(!0) | |
}, | |
84: function(t, e, n) { | |
n(83) | |
}, | |
85: function(t, e, n) { | |
t.exports = n(84) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment