Comments (12)
What is the actual use case here? It seems odd to attempt to limit the consumer of your component like this...
from rfcs.
To reply to @rwjblue comment on emberjs/ember.js#12968 (comment)
Here are a few examples I think could have benefited from this pattern:
A "navBar" component, that can only have "button" and "title" components. As the component's developer being able to only whitelist btn
and title
makes sure I have an integral control on the component's render state (ie. styles).
While this example demonstrate a purely "aesthetic" consideration, I've encountered multiple cases where I wanted to whitelist the elements being render for functional purposes.
For example: a horizontal-item-scroller component. In my specific case I'm using an external library to align elements within a carousel. These elements require specific class and tag names to work correctly. Therefore I'm introducing composable components that abstract setting these attributes on the element.
Adding an element that doesn't follow this API actually brakes the whole carousel (it's no better than not showing it)
from rfcs.
I don't think it makes sense to add this to the core framework, but I am definitely interested in exposing the hooks necessary to make this possible from an addon.
from rfcs.
@tomdale do you have a vague idea of which hooks could be leveraged to achieve this result? Even if they're private - for research purposes.
from rfcs.
If you really want that level of control, I would suggest not yielding. Yielding implies giving up control over what goes inside, and is why it's called "yield".
A nav bar that wants to define a restricted API can do so via it's own arguments, including taking components (with bound arguments and everything) as arguments, like:
{{nav-bar items=items button=(component "fancy-button" mode="wonderful") }}
from rfcs.
@ef4 I think attributes works OK when the number of arguments can be kept at a minimum level. It's not always possible. Imagine a jQuery.masonry
wrapper that requires children elements to be wrapped inside specific elements (as that's the only way for them to be positioned correctly).
While I understands what yield
does and why it was called like that, I don't think it's a strong enough argument against challenging its limits. It's not because it's named one way that we should never attempt to touch it nor question it.
Composable components are offering developers a great way to define declarative API. I'm sure they're only going to grow in popularity (especially when you see what the guys achieved with https://github.com/reactjs/react-router) and new patterns will emerge. I think exposing the relevant hooks for developers to be able to build upon it is a step in the right direction.
from rfcs.
Contextual handling of HTML/components has been anticipated by Glimmer, but still needs a long time to bake and it's not clear we want the feature at all as it complicates the mental model. The idea is to enable things like
The feature would have a similar spirit to the <table>
element in HTML and its contextual handling of <thead>
, <tbody>
, etc.
from rfcs.
@mmun where is it possible to follow the progress on this one?
from rfcs.
It should be possible to do this sort of assertion today via at least two mechanisms (possibly more):
- check the DOM in
didInsertElement
for development builds (viaEmber.runInDebug
), and throwing/asserting if you find malformed contents (this is public API) - write an AST transform that runs at template compile time, and asserts when invalid content exists (AST transforms are private API)
from rfcs.
@rwjblue thanks
from rfcs.
@olivierlesnicki I think this is superseded by #454 ?
from rfcs.
Closing!
from rfcs.
Related Issues (20)
- NVP todos
- Deprecate all of Ember Classic HOT 16
- Build-time configuration of index.html HOT 3
- Deprecate support for Travis CI HOT 6
- Deprecate `ember-mocha`? HOT 2
- Deprecate `ember-export-application-global` addon? HOT 4
- Run Prettier separately in `app` blueprint HOT 9
- Deprecate `app.import`
- Thoughts on this more ergonomic way to wire up the owner + destroyable association? HOT 2
- Explore "official" pod deprecation HOT 19
- {{else}} should render a value rather than be a control-flow keyword. HOT 5
- new primitive: transition, similar to modifiers, except they block certain render events HOT 2
- Numbers in PR titles affect automation
- Asset import spec RFC HOT 2
- Implement import spec RFC HOT 1
- Replacing `moduleName` in template meta HOT 11
- Simplified imports for common built-in modules HOT 2
- Pre-RFC: Add `aria-current` attribute to Ember's `LinkTo` component HOT 1
- Whitespace handling for `<template>` tag HOT 4
- Add LICENSE
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 rfcs.