Skip to content
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

GetElementByClass does not support elements with multiple classes #18

Open
norberturkiewicz opened this issue Jul 31, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@norberturkiewicz
Copy link

Currently the input must search by full class list

Fails

       body A.GetElementByClass'item-title'
undefined class: item-title
      body A.GetElementByClass'item-title'
           ∧

Works

      body A.GetElementByClass'left item-title'
#.Abacus.Main.[Namespace]
@norberturkiewicz norberturkiewicz added the bug Something isn't working label Jul 31, 2024
@norberturkiewicz norberturkiewicz changed the title GetElementByClass does not support elements with multiple classes defined GetElementByClass does not support elements with multiple classes Jul 31, 2024
@PaulMansour
Copy link
Contributor

We also don't seen to have GetElementsByClass (with an "s")...

@PaulMansour
Copy link
Contributor

Should we make it work on multiple classes:

d GetElementsByClass 'One' 'Two'

would then return elements that have both class One and Two. Or One or Two. Or just have it take only a single class, and then use ∩ and ∪ to get what you want.?

@norberturkiewicz
Copy link
Author

How would we determine and/or? What if I want class1 and class2 but they may be in different orders?

@PaulMansour
Copy link
Contributor

Order is no problem. I think we should just copy JavaScript which does an "and" ... all the classes must exist

@PaulMansour
Copy link
Contributor

GetElementsByClass←{
     ⍝ ⍺ ←→ Element (or result of Elements ⍺)
     ⍝ ⍵ ←→ Class(es) Simple or nested: 'One' or 'One Two' or 'One' 'Two'
     ⍝ ← ←→ Elements
     c←' '(≠⊆⊢)1↓∊' ',¨⊆⍵
     e←{1=⍴⍴⍵:⍵ ⋄ Elements ⍵}⍺
     b←e{2≠⍺.⎕NC'class':0 ⋄ ∧/⍵∊' '(≠⊆⊢)⍺.class}¨⊂c
     b/e
 }

@PaulMansour
Copy link
Contributor

Also, I think I should use "GetElementByTag" instead of "ElementByTag" and everywhere else, to be consistent with JavaScript internally consistent in Abacus....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants