use of com.axellience.vuegwt.processors.component.template.parser.context.localcomponents.LocalComponentProp in project vue-gwt by Axellience.
the class TemplateParser method processElementAttributes.
/**
* Process an {@link Element} and check for vue attributes.
* @param element Current element being processed
*/
private void processElementAttributes(Element element) {
Optional<LocalComponent> localComponent = getLocalComponentForElement(element);
// Iterate on element attributes
Set<LocalComponentProp> foundProps = new HashSet<>();
for (Attribute attribute : element.getAttributes()) {
if ("v-for".equals(attribute.getKey()) || "v-model".equals(attribute.getKey()))
continue;
Optional<LocalComponentProp> optionalProp = localComponent.flatMap(lc -> lc.getPropForAttribute(attribute.getName()));
optionalProp.ifPresent(foundProps::add);
if (!VUE_ATTR_PATTERN.matcher(attribute.getKey()).matches()) {
optionalProp.ifPresent(this::validateStringPropBinding);
continue;
}
context.setCurrentSegment(attribute);
currentAttribute = attribute;
currentProp = optionalProp.orElse(null);
currentExpressionReturnType = getExpressionReturnTypeForAttribute(attribute);
String processedExpression = processExpression(attribute.getValue());
if (attribute.getValueSegment() != null)
outputDocument.replace(attribute.getValueSegment(), processedExpression);
}
localComponent.ifPresent(lc -> validateRequiredProps(lc, foundProps));
}
Aggregations