瀏覽代碼

Fix bad hack of JsDom parser for :scope handling

jherve 1 年之前
父節點
當前提交
eaa5f9275e
共有 2 個文件被更改,包括 8 次插入6 次删除
  1. 4 2
      src/Node/JsDom.js
  2. 4 4
      test/JobsUnifiedTopCard.purs

+ 4 - 2
src/Node/JsDom.js

@@ -19,11 +19,12 @@ export const jsDomParse = function (string) {
           const [selector] = args;
 
           if (selector.startsWith(":scope")) {
+            const old_id = this.id;
             this.id = "scope";
             const ret = this.parentElement.querySelectorAll(
               selector.replace(":scope", "#scope")
             );
-            this.id = undefined;
+            this.id = old_id;
 
             return ret;
           } else {
@@ -41,11 +42,12 @@ export const jsDomParse = function (string) {
           const [selector] = args;
 
           if (selector.startsWith(":scope")) {
+            const old_id = this.id;
             this.id = "scope";
             const ret = this.parentElement.querySelector(
               selector.replace(":scope", "#scope")
             );
-            this.id = undefined;
+            this.id = old_id;
             return ret;
           } else {
             return querySelectorFunc.apply(this, args);

+ 4 - 4
test/JobsUnifiedTopCard.purs

@@ -69,7 +69,7 @@ testJobsUnifiedTopCard = do
               (DetachedElement {
                 classes: ("job-details-jobs-unified-top-card__job-insight-view-model-secondary" : Nil),
                 content: "Confirmé",
-                id: (Just "undefined"),
+                id: Nothing,
                 tag: "SPAN"
               })) : Nil))) }),
             icon: DetachedLiIcon "job"
@@ -77,21 +77,21 @@ testJobsUnifiedTopCard = do
           content: (TopCardInsightContentSingle (DetachedElement {
             classes: Nil,
             content: "201-500 employés · Technologies et services de l’information",
-            id: (Just "undefined"),
+            id: Nothing,
             tag: "SPAN" })),
           icon: DetachedLiIcon "company"
         }) : (TopCardInsight {
             content: (TopCardInsightContentSingle (DetachedElement {
               classes: Nil,
               content: "2 anciens élèves travaillent ici",
-              id: (Just "undefined"),
+              id: Nothing,
               tag: "SPAN" })),
             icon: DetachedLiIcon "people"
             }) : (TopCardInsight {
               content: (TopCardInsightContentSingle (DetachedElement {
                 classes: Nil,
                 content: "Découvrez comment vous vous positionnez par rapport à 87 candidats. Essai Premium pour 0 EUR",
-                id: (Just "undefined"),
+                id: Nothing,
                 tag: "SPAN" })),
               icon: (DetachedSvgElement { dataTestIcon: (Just "lightbulb-medium"), id: Nothing, tag: "svg" })
             }) : (TopCardInsight {