Comments (9)
I don't think this is necessary. I will try to more clearly describe under what conditions and how it is necessary to pass property values โโthrough attributes - I think this will be enough.
from hybrids.
I thought about the problem, and I added support for fallback to the camel-cased name in an expression: bdd8716
Also docs are updated and simplified.
You can try it out in v8.2.20
from hybrids.
I want to get the model and draft for a specific id:
This id is determined by the parent <comments-list>
via the comment-id
attribute.
But now it doesn't work.
from hybrids.
You must have been passing props/attrs wrong. This was not a breaking change, just a move of when the same thing happened.
Here you have a working example: https://stackblitz.com/edit/hybrids-simple-counter-mzkstz?file=src%2Findex.html,src%2Findex.js
I suppose, that you pass in your templates something like comment-id="${...}"
, which is not supported. Please read the docs here: https://hybrids.js.org/#/component-model/templates?id=properties-amp-attributes
Essentially, with that commit attributes are read when an element is upgraded, which is still correct with the docs - you should only use attributes when using them statically in the document/template.
from hybrids.
https://codepen.io/qsppl/pen/wvZxbOq?editors=1010
I've created an example showing all the invariants of passing properties to a component via attributes in a template. The current behavior is not obvious or intuitive. Many developers on my team also point out that this part of the documentation is difficult to understand.
If passing properties through attributes really should work the way it does now, then could you simplify the documentation on this topic?
from hybrids.
It's actually quite simple, inside of the hybrids templates just always use properties, like modelId
, it is just better in every way. I have never gotten confused about it (I know am an author, but I work with other programmers too). I also very rarely use external property to set store model id, as you can just pass it directly to the model name when using factory.
Many developers on my team also point out that this part of the documentation is difficult to understand.
This is something that for example lit-html
forces you to explicitly set if you pass a prop or an attribute. And in hybrids, it is here just for interoperability with custom elements created with other framework/vanilajs. You can create a custom element, which watches attribute changes but does not define related property. In that case, and only in that, hybrids template engine will set the attribute rather than the property.
The docs says:
If your template contains a custom element, that only supports attributes, you can use the original name:
I think this is super clear. The template engine can be used with external custom elements, that's why this feature exists.
If passing properties through attributes really should work the way it does now, then could you simplify the documentation on this topic?
You are always welcome to make hybrids better. If you think that docs could be written better, I'll be pleased to review your PR ;)
from hybrids.
One another thought. What could be done, is to add support for case-sensitive attributes inside of templates, but it might be very tricky, as <my-element modelId="1">
is just an element where there is no expression, so no entry point to look at.
In another point of view, this is just a limitation of the HTML itself, as it does not support case-sensitive attributes.
On another hand, the template engine cannot assume that <my-element model-id="${...}">
should set modelId
property, as the custom element can just utilize the model-id
attribute - and you cannot check it in any way from outside of the element definition.
from hybrids.
But English is not my native language, so the text may have a strange style)
from hybrids.
thank you very much, it became much more convenient
from hybrids.
Related Issues (20)
- Small Type Inferencing Issue with Property<E, V> HOT 6
- Cannot pass an object to the API via the "list" method HOT 7
- Expand the functionality of drafts
- sync() with nested models is broken HOT 4
- Allow storing an object in a component property HOT 4
- Add partial loading of model data HOT 3
- Why do you remove the lastValue? HOT 2
- The store logs a lot of errors HOT 4
- Convert a Whole Component to Web Component HOT 8
- Scoped CSS HOT 6
- lagging update glitch HOT 2
- Component properties cannot be setted until they are observed HOT 2
- `store.set()` is very slow HOT 5
- Store loads items data when iterating the list of items HOT 2
- store.record(store.record('')) bug HOT 3
- Protect Models from incorrect use HOT 9
- Passing a transform function to 'reflect:' in a property descriptor has no effect without also specifying an observer HOT 2
- Add nullable model values HOT 3
- 'Try to assert value of the '<property_name>' inside of the value function' error while passing children their properties HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hybrids.