Esempio n. 1
0
        public override IList <IHtmlValidationError> ValidateElement(ElementNode element)
        {
            var results = new ValidationErrorCollection();

            if (element.IsDocType())
            {
                return(results);
            }

            for (int i = 0; i < element.Attributes.Count; i++)
            {
                var attr = element.Attributes[i];

                if (attr.Name == "itemtype" && attr.HasValue() && !attr.Value.Contains("@"))
                {
                    if (!Uri.IsWellFormedUriString(attr.Value, UriKind.Absolute))
                    {
                        results.AddAttributeError(element, String.Format(CultureInfo.CurrentCulture, "The value of {0} must be an absolute URI", attr.Name), HtmlValidationErrorLocation.AttributeValue, i);
                        break;
                    }
                }
            }

            return(results);
        }
Esempio n. 2
0
        private bool ShouldIgnore(ElementNode element, AttributeNode attr)
        {
            // Ignore doctype
            if (element.IsDocType())
            {
                return(true);
            }

            // Ignore everything bug <ng-*> elements and ng-* attributes
            if (!element.Name.StartsWith("ng-", StringComparison.Ordinal) && (attr == null || attr.Name == "ng-app" || attr.Name == "data-ng-app"))
            {
                return(true);
            }

            // Ignore if <html> isn't present in the document (probably a partial or similar)
            if (!HasHtmlElement(element))
            {
                return(true);
            }

            // Follow the parent chain to find any ng-app attributes
            return(IsParentNgApp(element));
        }