Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next iteration of x-element (soon to be 1.0.0). #69

Merged
merged 1 commit into from
Dec 9, 2020

Conversation

theengineear
Copy link
Collaborator

@theengineear theengineear commented Dec 9, 2020

This closes #68, closes #67, closes #66, closes #57, closes #46, closes #42, closes #36, closes #31, closes #30, closes #28, closes #26, and closes #25.

This is a clean version of #58 — that PR began as an exploration and turned into a promising candidate for our initial 1.0.0. Since the discussions got lengthy in there, I decided to start fresh with a better branch name and a clean slate.

Significant changes:

  • Static analysis is done up-front, once.
  • Anything that can be validated statically throws errors
  • Environment / runtime errors console.warn (e.g., inherited property shadowing, data-* attributes, etc.)
  • Almost all of the XElement interface is static.
  • observer >> observe is now a function (proper context is maintained if it's a constructor method).
  • computed >> input + compute. compute is now a function. input is an array of property names which will be resolved to arguments at runtime and passed to compute.
  • value >> initial + default. initial is used if initial value is nullish. default is used if property value is ever nullish.
  • Type coercion is no longer done on set.
  • Errors are thrown when you set a value with an incorrect type in the runtime.
  • Concept of readOnly is first-class.
  • Concept of internal is first-class.
  • Internal setting/getting and read-only setting can be done via the .internal proxy.
  • Computed properties are now lazily evaluated.
  • Observation, reflection, and computation are no longer synchronous. Importantly, this allows us to set properties one-by-one and then get a single compute at the end.
  • Concept of a "render root" is now supported via createRenderRoot.
  • We always allow computation of computed properties before any arguments are defined. Previously, we had questioned that approach.
  • Swapped the order of values in observe callbacks to be value, oldValue — it was previously oldValue, value.
  • Order of operations are now compute, reflect, render, then observe.
  • Listener logic has been improved and interface is now a function, not a string.
  • All callbacks are bound to the constructor (e.g., compute, listen, observe, etc).
  • Coercion of null and undefined to '' is removed, the underlying templating engine takes care of this for us.
  • Deserialization of anything other than [Boolean, String, Number] now throws a halting error (e.g., setting an attribute for a property that is of type: Object).

This closes #68, closes #67, closes #66, closes #57, closes #46,
closes #42, closes #36, closes #31, closes #30, closes #28, closes #26,
and closes #25.
@theengineear
Copy link
Collaborator Author

FYI @klebba — I think we're finally ready to merge this!

@theengineear theengineear mentioned this pull request Dec 9, 2020
@theengineear
Copy link
Collaborator Author

Note — we will probably bump to 1.0.0-rc.41 before finally moving to 1.0.0. The important part is that we should be clear to merge this in and release 👌

@theengineear theengineear merged commit c5440e3 into master Dec 9, 2020
@theengineear theengineear deleted the x-element-next branch December 9, 2020 17:58
@theengineear theengineear mentioned this pull request Dec 10, 2020
@klebba
Copy link
Collaborator

klebba commented Dec 11, 2020

@theengineear awesome work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment