Closed paulirish closed 8 years ago
This looks like a really good idea!
I'm tempted to use @dglazkov's library as I could just install it as a sub-dependency. If I were to use @esprehn's then it would be more of a copy/paste job; but if that meant he could depend directly on fastdom
in his project, that would be cool.
Overall I'm drawn to the simplicity of @dglazkov's library, but could be persuaded otherwise :)
well, tbh in both cases, I am not sure we can reliably expect either repo to be maintained, the code will have to move into this project.
that said, elliott built off dimitri's original nope work, and essentially v2'd it in fx-framework.
Questions:
window.innerWidth
trigger reflow? I'm pretty sure in Gecko it's free, in which case we don't need to spy on it.element.style.set('foo', ...)
instead of element.style.foo = ...
. Likewise for dataset
. This breaks apps. I can't think of another way to wrap it without using Proxy
, which isn't supported in Chrome.FORBIDDEN
APIs. This seems a little out of scope for Fastdom; considering removing.Does window.innerWidth trigger reflow? I'm pretty sure in Gecko it's free, in which case we don't need to spy on it.
I forgot to mention that, in Gecko, this is not free when called inside nested window (iframe).
window.innerWidth
is a value
in Blink, but a get
function in Gecko. The Blink implementation requires more creative hacks in order to wrap.@paulirish I've landed strict-mode in v1-beta
branch. Would love a sanity check before merging to master.
fastdom.js
and fastdom-strict.js
which wraps window.fastdom
.1.2kb
compressed).strictdom
is a standalone repo to encourage use by other libraries.I still need to amend the readme to cover new concepts.
Cheers pal :)
Landed in master f8760dd51f6d7c6573771ecdd39850f1f045f9c0
this is epic. nice work with https://github.com/wilsonpage/strictdom !
People have asked for this many times: "yell at me if I'm doing DOM work outside of these methods, so I don't accidentally regress things."
Previous efforts to enforce fastDOM phases:
This last implementation by @esprehn is particularly mature.
It can validate that reads and writes happen when they should and can optionally enforce neither read nor write happens outside of the predefined methods (by setting this to
FORBIDDEN
).I think it would make a lot of sense to introduce the strict mode from fastdom.js (or maybe fastdom-full.js). (Of course: Elliot is happy to see his work folded into fastDOM.)
Caveats: Currently the implementation does require a slightly different API for classList and inline style, but if we're willing to accept 20ms of extra cost, it can preserve all the same APIs. The only downside is that
elem.dataset
isn't included; it's DOM got too magic, yo.IMO, It would make sense as a development-only lint/strict mode, and isn't intended for production. (Browser support for this sort of thing will be very spotty).
All in all this feels pretty compelling. And would certainly make a big splash with 1.0. What do ya'll think?