-
Notifications
You must be signed in to change notification settings - Fork 41
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
feat: NS class selectors #175
base: master
Are you sure you want to change the base?
Changes from 13 commits
c360f22
3f01f7a
e4ccc66
54a8051
63285d4
3c97c7a
07caf86
d2604fe
5cd6ca3
42d5542
67b7467
ed2de93
21babdd
499fcca
a50f7b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,20 +6,20 @@ | |
"elm-version": "0.19.1", | ||
"dependencies": { | ||
"direct": { | ||
"elm/browser": "1.0.0", | ||
"elm/core": "1.0.0", | ||
"elm/browser": "1.0.1", | ||
"elm/core": "1.0.5", | ||
"elm/html": "1.0.0", | ||
"elm/json": "1.0.0", | ||
"elm/json": "1.1.3", | ||
"elm/random": "1.0.0", | ||
"elm/svg": "1.0.0", | ||
"elm/svg": "1.0.1", | ||
"elm/time": "1.0.0", | ||
"elm/url": "1.0.0", | ||
"elm/virtual-dom": "1.0.0", | ||
"elm/virtual-dom": "1.0.2", | ||
"elm-explorations/linear-algebra": "1.0.3", | ||
"elm-explorations/markdown": "1.0.0", | ||
"elm-explorations/test": "1.2.2", | ||
"elm-explorations/webgl": "1.0.1", | ||
"jinjor/elm-diff": "1.0.5", | ||
"elm-explorations/webgl": "1.1.3", | ||
"jinjor/elm-diff": "1.0.6", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather we not update this file if possible, just to make sure everything still works with the older versions - to minimize the chances that these changes cause regressions for anyone! 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done 👍 |
||
"rtfeldman/elm-validate": "4.0.1" | ||
}, | ||
"indirect": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,12 @@ module Test.Html.SelectorTests exposing (all) | |
-} | ||
|
||
import Fuzz exposing (..) | ||
import Html exposing (Html, a, div, footer, header, li, section, span, ul) | ||
import Html | ||
import Html.Attributes as Attr | ||
import Svg | ||
import Svg.Attributes as SvgAttribs | ||
import Test exposing (..) | ||
import Test.Html.Query as Query exposing (Single) | ||
import Test.Html.Query as Query | ||
import Test.Html.Selector exposing (..) | ||
|
||
|
||
|
@@ -16,6 +18,104 @@ all = | |
describe "Test.Html.Selector" | ||
[ bug13 | ||
, textSelectors | ||
, classSelectors | ||
, attributeSelectors | ||
, nsSelectors | ||
] | ||
|
||
|
||
nsSelectors : Test | ||
nsSelectors = | ||
describe "NS selectors" | ||
[ test "classNS selector finds class on svg with one class" <| | ||
\() -> | ||
let | ||
svgClass = | ||
"some-NS-class" | ||
in | ||
Svg.svg | ||
[ SvgAttribs.class svgClass ] | ||
[ Svg.circle [ SvgAttribs.cx "50", SvgAttribs.cy "50", SvgAttribs.r "40" ] [] ] | ||
|> Query.fromHtml | ||
|> Query.has [ classNS svgClass ] | ||
, test "classNS selector finds class on svg with multiple classes" <| | ||
\() -> | ||
let | ||
svgClass = | ||
"some-NS-class" | ||
in | ||
Svg.svg | ||
[ SvgAttribs.class svgClass, SvgAttribs.class "another-NS-class" ] | ||
[ Svg.circle [ SvgAttribs.cx "50", SvgAttribs.cy "50", SvgAttribs.r "40" ] [] ] | ||
|> Query.fromHtml | ||
|> Query.has [ classNS svgClass ] | ||
, test "classesNS selector finds all classes on svg" <| | ||
\() -> | ||
let | ||
svgClass = | ||
"some-NS-class" | ||
in | ||
Svg.svg | ||
[ SvgAttribs.class svgClass, SvgAttribs.class "another-NS-class" ] | ||
[ Svg.circle [ SvgAttribs.cx "50", SvgAttribs.cy "50", SvgAttribs.r "40" ] [] ] | ||
|> Query.fromHtml | ||
|> Query.has [ classesNS [ svgClass, "another-NS-class" ] ] | ||
, test "classesNS selector finds single class on svg with multiple classes" <| | ||
\() -> | ||
let | ||
svgClass = | ||
"some-NS-class" | ||
in | ||
Svg.svg | ||
[ SvgAttribs.class svgClass, SvgAttribs.class "another-NS-class" ] | ||
[ Svg.circle [ SvgAttribs.cx "50", SvgAttribs.cy "50", SvgAttribs.r "40" ] [] ] | ||
|> Query.fromHtml | ||
|> Query.has [ classesNS [ svgClass ] ] | ||
, test "exactClassNameNS selector finds the exact class value on svg" <| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure that we should support There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm.. I don't quite understand? Could you elaborate? |
||
\() -> | ||
let | ||
svgClass = | ||
"some-NS-class another-NS-class" | ||
in | ||
Svg.svg | ||
[ SvgAttribs.class svgClass ] | ||
[ Svg.circle [ SvgAttribs.cx "50", SvgAttribs.cy "50", SvgAttribs.r "40" ] [] ] | ||
|> Query.fromHtml | ||
|> Query.has [ exactClassNameNS svgClass ] | ||
] | ||
|
||
|
||
attributeSelectors : Test | ||
attributeSelectors = | ||
describe "attribute selectors" | ||
[ test "attribute selector does not find class on svg elements" <| | ||
\() -> | ||
let | ||
svgClass = | ||
"some-NS-class" | ||
in | ||
Svg.svg | ||
[ SvgAttribs.class svgClass ] | ||
[ Svg.circle [ SvgAttribs.cx "50", SvgAttribs.cy "50", SvgAttribs.r "40" ] [] ] | ||
|> Query.fromHtml | ||
|> Query.hasNot [ attribute (SvgAttribs.class svgClass) ] | ||
] | ||
|
||
|
||
classSelectors : Test | ||
classSelectors = | ||
describe "class selectors" | ||
[ test "does not find class on svg elements" <| | ||
\() -> | ||
let | ||
svgClass = | ||
"some-NS-class" | ||
in | ||
Svg.svg | ||
[ SvgAttribs.class svgClass ] | ||
[ Svg.circle [ SvgAttribs.cx "50", SvgAttribs.cy "50", SvgAttribs.r "40" ] [] ] | ||
|> Query.fromHtml | ||
|> Query.hasNot [ class svgClass ] | ||
] | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this lower bound be
1.0.0
instead of1.0.1
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍