Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit ada5491

Browse files
committed
XmlComponent: no attributes on hx:Declarations
1 parent eba7e00 commit ada5491

1 file changed

Lines changed: 14 additions & 21 deletions

File tree

src/com/feathersui/xml/XmlComponent.hx

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -379,13 +379,7 @@ class XmlComponent {
379379
continue;
380380
}
381381

382-
for (attribute in child.attributes()) {
383-
if (attribute == "id") {
384-
continue;
385-
}
386-
var attrPos = xmlDocument.getAttrPosition(child, attribute);
387-
errorAtXmlPosition('Unknown field \'${attribute}\'', attrPos);
388-
}
382+
checkForInvalidAttributes(child, true, xmlDocument);
389383
var fieldType = foundField != null ? foundField.type : null;
390384
parseChildrenForField(child, child.iterator(), targetIdentifier, foundField, childXmlName.localName, fieldType, prefixMap, parentFields,
391385
initExprs, xmlDocument);
@@ -453,8 +447,19 @@ class XmlComponent {
453447
parentFields, initExprs, xmlDocument);
454448
}
455449

450+
private static function checkForInvalidAttributes(element:Xml, allowId:Bool, xmlDocument:Xml176Document):Void {
451+
for (attribute in element.attributes()) {
452+
if (allowId && attribute == "id") {
453+
continue;
454+
}
455+
var attrPos = xmlDocument.getAttrPosition(element, attribute);
456+
errorAtXmlPosition('Unknown field \'${attribute}\'', attrPos);
457+
}
458+
}
459+
456460
private static function parseDeclarations(element:Xml, prefixMap:Map<String, String>, parentFields:Array<Field>, initExprs:Array<Expr>,
457461
xmlDocument:Xml176Document):Void {
462+
checkForInvalidAttributes(element, false, xmlDocument);
458463
for (child in element.iterator()) {
459464
switch (child.nodeType) {
460465
case Element:
@@ -464,13 +469,7 @@ class XmlComponent {
464469
var initExpr:Expr = null;
465470
if (isBuiltIn(childXmlName, prefixMap) && childXmlName.localName != "Dynamic" && childXmlName.localName != "Any"
466471
&& childXmlName.localName != "Array") {
467-
for (attribute in child.attributes()) {
468-
if (attribute == "id") {
469-
continue;
470-
}
471-
var attrPos = xmlDocument.getAttrPosition(child, attribute);
472-
errorAtXmlPosition('Unknown field \'${attribute}\'', attrPos);
473-
}
472+
checkForInvalidAttributes(child, true, xmlDocument);
474473
for (grandChild in child.iterator()) {
475474
var str = StringTools.trim(grandChild.nodeValue);
476475
initExpr = createValueExprForDynamic(str);
@@ -532,13 +531,7 @@ class XmlComponent {
532531
&& childXmlName.localName != "Dynamic"
533532
&& childXmlName.localName != "Any"
534533
&& childXmlName.localName != "Array") {
535-
for (attribute in child.attributes()) {
536-
if (attribute == "id") {
537-
continue;
538-
}
539-
var attrPos = xmlDocument.getAttrPosition(child, attribute);
540-
errorAtXmlPosition('Unknown field \'${attribute}\'', attrPos);
541-
}
534+
checkForInvalidAttributes(child, true, xmlDocument);
542535
for (grandChild in child.iterator()) {
543536
if (!isArray && valueExprs.length > 0) {
544537
errorAtXmlPosition('The child of type \'${grandChild.nodeType}\' is unexpected', xmlDocument.getNodePosition(child));

0 commit comments

Comments
 (0)