Open norberturkiewicz opened 3 months ago
We also don't seen to have GetElementsByClass (with an "s")...
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.?
How would we determine and/or? What if I want class1 and class2 but they may be in different orders?
Order is no problem. I think we should just copy JavaScript which does an "and" ... all the classes must exist
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
}
Also, I think I should use "GetElementByTag" instead of "ElementByTag" and everywhere else, to be consistent with JavaScript internally consistent in Abacus....
Currently the input must search by full class list
Fails
Works