[gxml] CssSelectorParser.match() implement .warning (class)
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] CssSelectorParser.match() implement .warning (class)
- Date: Wed, 6 Sep 2017 16:17:16 +0000 (UTC)
commit 892bee0ed0dfeaac6389f3ab2a13405527d1ea67
Author: Daniel Espinosa <esodan gmail com>
Date: Wed Sep 6 09:06:48 2017 -0700
CssSelectorParser.match() implement .warning (class)
gxml/GXmlDomCollections.vala | 2 ++
gxml/css-selector-parser.vala | 20 +++++++++++++++++++-
2 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/gxml/GXmlDomCollections.vala b/gxml/GXmlDomCollections.vala
index 6d04eb6..3d2d86c 100644
--- a/gxml/GXmlDomCollections.vala
+++ b/gxml/GXmlDomCollections.vala
@@ -43,6 +43,8 @@ public class GXml.GDomTokenList : Gee.ArrayList<string>, GXml.DomTokenList {
for (int i = 0; i < s.length; i++) {
(this as Gee.ArrayList<string>).add (s[i]);
}
+ } else {
+ (this as Gee.ArrayList<string>).add (av);
}
}
}
diff --git a/gxml/css-selector-parser.vala b/gxml/css-selector-parser.vala
index fe13dd3..7445a9e 100644
--- a/gxml/css-selector-parser.vala
+++ b/gxml/css-selector-parser.vala
@@ -1,4 +1,4 @@
-/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 0; tab-width: 2 -*- */
+/* -*- Mode: vala; indent-tabs-mode: tab; c-basic-offset: 0; tab-width: 2 -*- */
/*
*
* Copyright (C) 2017 Yannick Inizan <inizan yannick gmail com>
@@ -275,6 +275,10 @@ public class GXml.CssSelectorParser : GLib.Object {
}
if (u == '*')
parse_all (css, ref position);
+ else if (u == '.') {
+ parse_class (css, ref position);
+ continue;
+ }
else if (u.isalnum())
parse_element (css, ref position);
else if (u == ',') {
@@ -329,6 +333,20 @@ public class GXml.CssSelectorParser : GLib.Object {
if (p == null) return false;
if (p == s.value) return true;
}
+ if (s.selector_type == CssSelectorType.CLASS) {
+ var p = element.get_attribute ("class");
+ if (p == null) return false;
+ message (p+": "+s.data);
+ var lc = element.class_list;
+ message (lc.length.to_string ());
+ for (int k = 0; k < lc.length; k++) {
+ var cl = lc.item (k);
+ if (cl == null) continue;
+ if (cl.down () == s.data.down ()) return true;
+ }
+ if (lc.contains (s.data)) return true;
+ if (p=="warning") warning ("Not found");
+ }
}
return false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]