-
Notifications
You must be signed in to change notification settings - Fork 90
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
Allow collections to have a parm for options #474
Comments
Hey, thank you for opening the ticket! I think this is more related to components query API rather than collection API. For instance, let's assume the following markup: <section class="MyComponent">
<div>1</div>
<div>2</div>
<div>3</div>
</div> Here we have the same issue, so in order to reference children {
scope: '.MyComponent',
column1: {
scope: 'div:nth-child(1)'
},
column2: {
scope: 'div:nth-child(2)'
},
column3: {
scope: 'div:nth-child(3)'
}
} cause we don't have TBH, I'm not sure if we really have to improve positional query APIs( It might be not applicable for each project, but in order to avoid this issue, in my projects, I usually mark each column with it's own class or data-test attribute to avoid the need for selecting by position, so we have smth like: {{#let "MyComponent" as |scope|}}
<section class="{{scope}}">
<div class="{{scope}}-c1">1</div>
<div class="{{scope}}-c2">2</div>
<div class="{{scope}}-c3">3</div>
</div>
{{/let}} const scope = .MyComponent';
{
scope,
column1: {
scope: `${scope}-c1`
},
column2: {
scope: `${scope}-c2`
},
column3: {
scope: `${scope}-c3`
}
} which leads to a more stable page object, because we rely on semantic rather than position. Would it work for you? Is |
Yea I can definitively see that the drug information is not really a collection, but was the closest I saw. I in fact did use a component with the at encoded as a nth-child and having AT at the component level would have been more correct. Assigning each inner div its own class would have removed the ATs on the 4 divs and Im fine with going that way. The real crux of the matter is the at on the drugInformation, I suggested collection because thats were you are already teaching at, but agree an at on the component definition may be more accurate |
I see what you mean, and I thiknk you are right. It seems a good idea to unify query API. Though adding the second collection argument for query configuration may feel natural comparing to the rest of props like drugInformation: collection('td', {
at: 2,
resetScope: false
}, {
resetScope: true,
text: text('div', { at: 1 })
}); should If talking about adding the I believe a good approach may be to support With that we can easily achieve an aligned API, so you example would be possible to express, like: rows: collection('.clinical-order-dispense table tbody tr', {
dispenseDateTime: text({
selector: 'td',
at: 0
}),
serialNumber: text({
selector: 'td',
at: 1
}),
drugInformation: {
scope: {
selector: "td",
at: 2
},
drug: text({
selector: 'div',
at: 0
}),
// ...
}
}) |
What you have at the bottom is what I would have expected. You did combine selector and options, which makes scope work really well and the change to text() to combine them does make then all look and act the same. But the change to text() and other actions will be a large lift for everyone to upgrade. I would hope you would plan on supporting |
Ok, so I found that the Code I have in a previous comment, using the
rewritten code using
Things to note.
|
I do like the change to
|
Great findings! I was not aware I'm surprised by
if feels like
yes, I can understand mirgration pain of such a breaking change and I don't intend to break it, at least in a foreseeable future. |
Should this issue be closed and another open to actually implement the changes to at? |
yes, I think we can close it, cause sounds like it's possible to lookup component by And it'd be nice to figure out |
Most of the items allow for a options hash, for example, text as in
The options hash is providing the
{ at: 1}
. I had a set of divs inside atd
and collection does not provide an options hash. The code I wrote wasseems weird I can use
{ at: 2 }
where needed except had to resort totd:nth-child(3)
If collection allowed for the option hash, I assume I could have written
The text was updated successfully, but these errors were encountered: