-
Notifications
You must be signed in to change notification settings - Fork 15
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
Simplify x-element. #58
Conversation
@klebba — mind taking a look when you have the chance? Also happy to walk you through the changes. I think you'll like the general direction here. |
3e1f97d
to
580b24c
Compare
The most recent change is because I was using some functionality not supported in eslint yet because it's stage 3 functionality. I didn't think the code suffered much to walk it back, so I just made sure it adhered to stage 4 functionality. |
580b24c
to
858efa3
Compare
@klebba — I left a couple things in limbo here. Please hold off on looking at the code until I get the chance to fix. |
8f782c4
to
e0ff8c5
Compare
I tried swapping this in for a feature I'm working and might have caught an issue; my observer functions are not being called yet. Here's my property block:
My demo page has markup like:
So some of the values need to be read immediately following element upgrade. Also I just grabbed whatever I saw in the PR for |
The initial update is done synchronously upon the first I think that your component will be supported, the PR has just been thrashing a bit. Importantly, I think that properties block is looking good! As a reminder, the new way you'd want to write this would be like: class CustomElement extends XElement {
static get properties() {
return {
targetRect: {
type: DOMRect,
},
open: {
type: Boolean,
reflect: true,
observer: this.observeOpen,
},
parentElement: {
type: HTMLElement,
internal: true,
},
cssProperties: {
type: Object,
internal: true,
dependencies: ['parentElement', 'targetRect', 'open'],
resolver: this.computeCSSProperties,
observer: this.observeCSSProperties,
},
};
}
} |
b797199
to
f359e62
Compare
@klebba I circled back on the issue you were having and perhaps there is a different bug that I'm misunderstanding. I've had a test in place the entire time to ensure that resolved, observed properties are synchronously called upon initial connection. Would you mind trying to create a minimal example element that demonstrates your issue? It'd be super helpful! |
OK, I'm willing to say that it makes sense to start trying to use this in your work as an experiment. I'm quite sure there will be some issues that need ironing out, but things should be stabilizing at this point. |
509c148
to
819f355
Compare
Let's start curating a migration guide: was:
now:
was:
now:
Also a question; if I throw in a resolver function what happens? |
This throw an error:
If I remove the |
a856fb9
to
a740af1
Compare
7e3d315
to
f88370b
Compare
I hit an issue with a Edit: Damn, the lazily evaluated properties got me again! 🤦 However this time adding an |
Is it possible to throw an error when a |
f88370b
to
4672d38
Compare
Yep, we stopped forcing the compute callbacks inside render completely now. I don't understand why setting a dummy
☝️ I'd expect that to work. Note that observe is called after render — could that be the issue? You're getting the side effect, but it's happening only render has occurred? If that's the case, you could also pluck it from the properties proxy inside your render routine.
|
For sure, we do that for the static listeners block — seems consistent to do it when using |
4672d38
to
48ba524
Compare
@klebba — EDIT: Actually, I went ahead and validated all the arguments 👌 |
48ba524
to
ac04e03
Compare
Based on our conversation I reworked my |
ac04e03
to
eb2c30c
Compare
@klebba — the |
eb2c30c
to
7d459bd
Compare
7d459bd
to
009e660
Compare
@codeStryke — as requested, I updated the documentation in the source code. |
@theengineear can you remind me what all remains here? If my memory serves, we're really close! 🥇 |
We need to complete the refactor in our application to prove that we like
this change set. Then, we can merge / publish. There's no real reason to
merge this PR in before we've finished testing it on the ~500 components we
have IMO. At a minimum, I'd like to get 50% of these components refactored
before merging this in. We can always merge it and then wait to publish.
It's just that once we merge it in, we break our ability to introduce any
sort of hot-fix.
…On Sat, Sep 26, 2020 at 4:42 PM Casey ***@***.***> wrote:
@theengineear <https://github.com/theengineear> can you remind me what
all remains here? If my memory serves, we're really close! 🥇
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#58 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABSOEWU6JNW2A7NIFM2QN33SHZ35DANCNFSM4NJ4XLWA>
.
|
009e660
to
8f4c795
Compare
OK — new branch, new PR. I'm going to close down this exploratory PR in favor of a fresh start (just a copy of what's here). Let's continue the discussion (if there's more to discuss) on #69. |
Concept branch — the goal here is to reimagine
x-element
based on our learnings from using it in hundreds of components in a complex SPA over the last year.Significant changes:
console.warn
in this case.render
is the only non-trivial instance method.#
) static fields when they're ready.observer
>>observe
is now a function (proper context is maintained if it's a constructor method).computed
>>input
+compute
.compute
is now a function (proper context is maintained if it's a constructor method).input
is an array of property names which will be resolved to arguments at runtime and passed tocompute
.value
is nowinitial
anddefault
.initial
is used if initial value is nullish.default
is used if property value is ever nullish.readOnly
is first-class.internal
is first-class..internal
proxy.compute
at the end.createRenderRoot
.observe
callbacks to bevalue, oldValue
— it was previouslyoldValue, value
.null
andundefined
to''
is removed, the underlying templating engine takes care of this for us.null
andundefined
to the empty string. However, that is handled by the templating engine now.[Boolean, String, Number]
now throws a halting error (e.g., setting an attribute for a property that is oftype: Object
). Previously, we basically did nothing, especially for custom classes.