Quellcode durchsuchen

Better handling of empty classList

jherve vor 1 Jahr
Ursprung
Commit
32e325234e
3 geänderte Dateien mit 15 neuen und 10 gelöschten Zeilen
  1. 6 1
      src/LinkedIn/DetachedNode.purs
  2. 4 4
      test/ArtDecoCard.purs
  3. 5 5
      test/JobsUnifiedTopCard.purs

+ 6 - 1
src/LinkedIn/DetachedNode.purs

@@ -13,6 +13,7 @@ import Data.String (Pattern(..))
 import Data.String as S
 import Data.String.CodeUnits (fromCharArray, toCharArray)
 import Data.Traversable (sequence)
+import Debug (trace)
 import Effect (Effect)
 import Partial.Unsafe (unsafePartial)
 import Web.DOM (Node)
@@ -88,7 +89,11 @@ elementToDetached el = case E.tagName el of
   where
     getClassList el' = do
       classStr <- E.className el'
-      pure $ A.toUnfoldable $ S.split (Pattern " ") (normalize classStr)
+      let
+        list = case normalize classStr of
+          "" -> Nil
+          str -> A.toUnfoldable $ S.split (Pattern " ") str
+      pure list
 
     getId el' = do
       id <- E.id el'

Datei-Diff unterdrückt, da er zu groß ist
+ 4 - 4
test/ArtDecoCard.purs


+ 5 - 5
test/JobsUnifiedTopCard.purs

@@ -54,14 +54,14 @@ testJobsUnifiedTopCard = do
         (NonEmpty (TopCardInsight {
           content: (TopCardInsightContentSecondary {
             primary: (DetachedElement {
-              classes: ("" : Nil),
+              classes: Nil,
               content: "Sur site",
               id: Nothing,
               tag: "SPAN"
             }),
             secondary: (NonEmptyList (NonEmpty (TopCardSecondaryInsightNested
               (DetachedElement {
-                classes: ("" : Nil),
+                classes: Nil,
                 content: "Temps plein",
                 id: Nothing,
                 tag: "SPAN"
@@ -75,21 +75,21 @@ testJobsUnifiedTopCard = do
             icon: DetachedLiIcon "job"
         }) ((TopCardInsight {
           content: (TopCardInsightContentSingle (DetachedElement {
-            classes: ("" : Nil),
+            classes: Nil,
             content: "201-500 employés · Technologies et services de l’information",
             id: (Just "undefined"),
             tag: "SPAN" })),
           icon: DetachedLiIcon "company"
         }) : (TopCardInsight {
             content: (TopCardInsightContentSingle (DetachedElement {
-              classes: ("" : Nil),
+              classes: Nil,
               content: "2 anciens élèves travaillent ici",
               id: (Just "undefined"),
               tag: "SPAN" })),
             icon: DetachedLiIcon "people"
             }) : (TopCardInsight {
               content: (TopCardInsightContentSingle (DetachedElement {
-                classes: ("" : Nil),
+                classes: Nil,
                 content: "Découvrez comment vous vous positionnez par rapport à 87 candidats. Essai Premium pour 0 EUR",
                 id: (Just "undefined"),
                 tag: "SPAN" })),