[gxml] Changing order for DomElement.get_elements_by_class_name()
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Changing order for DomElement.get_elements_by_class_name()
- Date: Wed, 14 Sep 2016 17:50:41 +0000 (UTC)
commit 920d53fca8b60807eef8887115bc2a4a2bf70f70
Author: Daniel Espinosa <esodan gmail com>
Date: Wed Sep 14 12:46:50 2016 -0500
Changing order for DomElement.get_elements_by_class_name()
* Now first add it self before to add descendant nodes
* Fixed too order for DomElement.get_elements_by_tag_name_ns()
gxml/GXmlElement.vala | 43 +++++++++++++++++++++++--------------------
1 files changed, 23 insertions(+), 20 deletions(-)
---
diff --git a/gxml/GXmlElement.vala b/gxml/GXmlElement.vala
index 509a266..d5f3d04 100644
--- a/gxml/GXmlElement.vala
+++ b/gxml/GXmlElement.vala
@@ -240,20 +240,22 @@ public class GXml.GElement : GXml.GNonDocumentChildNode,
public DomHTMLCollection get_elements_by_tag_name (string local_name) {
var l = new GDomHTMLCollection ();
+ //FIXME: quircks mode not considered
foreach (GXml.DomElement n in children) {
if (n.node_name == local_name)
- l.add ((DomElement) n);
+ l.add (n);
l.add_all (n.get_elements_by_tag_name (local_name));
}
return l;
}
public DomHTMLCollection get_elements_by_tag_name_ns (string? namespace, string local_name) {
var l = new GDomHTMLCollection ();
+ //FIXME: quircks mode not considered
foreach (GXml.DomElement n in children) {
- l.add_all (n.get_elements_by_tag_name_ns (namespace, local_name));
if (n.node_name == local_name
&& n.namespace_uri == namespace)
l.add (n);
+ l.add_all (n.get_elements_by_tag_name_ns (namespace, local_name));
}
return l;
}
@@ -266,28 +268,29 @@ public class GXml.GElement : GXml.GNonDocumentChildNode,
} else
cs += class_names;
foreach (GXml.DomElement n in children) {
- l.add_all (n.get_elements_by_class_name (class_names));
string cls = n.get_attribute ("class");
- if (cls == null) continue;
- string[] ncls = {};
- if (" " in cls)
- ncls = cls.split (" ");
- else
- ncls += cls;
- int found = 0;
- foreach (string cl in cs) {
- foreach (string ncl in ncls) {
- if (cl == ncl) {
- found++;
+ if (cls != null) {
+ string[] ncls = {};
+ if (" " in cls)
+ ncls = cls.split (" ");
+ else
+ ncls += cls;
+ int found = 0;
+ foreach (string cl in cs) {
+ foreach (string ncl in ncls) {
+ if (cl == ncl) {
+ found++;
+ }
}
}
+ if (found == cs.length) {
+ if (l.size == 0)
+ l.add (n);
+ else
+ l.insert (0, n);
+ }
}
- if (found == cs.length) {
- if (l.size == 0)
- l.add (n);
- else
- l.insert (0, n);
- }
+ l.add_all (n.get_elements_by_class_name (class_names));
}
return l;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]