Comments (5)
Another use case for this actually has intermediate-template in a loop, so it is actually called as <intermediate-template w-id="items[]" />
, even though we never actually use items[x]
, only items[x]-subwidget-id
. That use case is a bit more complex but could be tied to the same underlying process. I don't have any opinion one way or another on giving the intermediate template a w-id
, but I would just like to be able to save on shipping down widget code if nothing will use it.
from marko-widgets.
Hi @jackhorton, it seems reasonable that you might want to break up a UI component into multiple templates (hopefully within the single directory for the UI component). It seems pretty doable to support this, I'm going to need to take a closer look to get a better idea of the scope of work. I know it will require some changes to the compile-time transform that we are using to process the Marko template files, but I don't think the work is too much. I'll send an update soon. Thanks for opening the Github issue.
from marko-widgets.
New version published with enhancement: [email protected]
from marko-widgets.
Hi @jackhorton, please let me know if things work as expected with the latest code that now allows w-id
to be used in an intermediate template for a UI component. I have added a test case that validates the new functionality. Thanks.
from marko-widgets.
This works, though not entirely as expected. Given my second example, where the intermediate template is called in a loop, we may want to namespace it a bit.
Given a container.marko as such...
<div w-bind>
<intermediate-template w-id="group[]" />
</div>
... with everything else the same as in my original post, every single widget-*.marko
is added directly to the group[]
array. Even if we give the sub-widgets a declared w-id, it gets overwritten. So, in this example, the ids on the page turn out as follows: w0
, w0-group[0]
, w0-group[1]
, w0-group[2]
, w0-group[3]
, rather than what I was expecting, w0
, w0-group[0]-widget-one
, w0-group[0]-widget-two
, w0-group[0]-widget-three
, w0-group[0]-maybe-this-has-a-really-special-id
. Perhaps the worse problem is that if intermediate-template
is given a non-array w-id, it still overwrites them all, but then you just have a bunch of nodes with "w0-group" as each one's ID, which will cause issues.
So, the way that it exists now, at least in the array implementation, isn't really a problem for us, because we can still call getWidgets("group") on the container and get every widget south of it, which is what we are using it for. I guess the concern is that it will silently overwrite assigned w-ids on sub-widgets, and in the process would break getWidget() functionality. I have not determined what would happen if there was another sub-sub-widget in one of the sub-widgets, but i would imagine it also just gets added to the array.
from marko-widgets.
Related Issues (20)
- Proposal: Marko Widgets with ES6 and inline Marko templates HOT 6
- Bubbling event listeners are attached too late HOT 1
- Listeners for event delegation do not work if `document.body` is not available HOT 1
- w- prefix HOT 1
- Add support for csp nonce HOT 1
- Add support for delaying widget destruction from an onBeforeDestroy handler HOT 2
- Macro tag doesn't play well with w-bind / widget
- Bug: w-onchange adds "|w0" for null input HOT 1
- No error message when `w-bind` is used and no `index.js` or `widget.js` is found
- Out parameter?
- w-for attribute not being removed HOT 1
- event-delegation.js:44 Uncaught TypeError: Cannot read property '__widget' of null HOT 1
- Proposal: Template as entry point for UI components HOT 6
- Getting the nested widget instance
- Declarative DOM event listeners broken for non-bubbling events on repeated elements HOT 1
- Make state property full reactively HOT 3
- Missing something with lasso and marko-widgets
- Calling A component in for loop . only trigering first element HOT 3
- Extra event handlers are getting added when noConflict js containing marko widgets is loaded
- Special unicode chars (\u2028 and \u2029) need to be escaped if within script tag
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 marko-widgets.