    001// Copyright 2013 The Apache Software Foundation
    002//
    003// Licensed under the Apache License, Version 2.0 (the "License");
    004// you may not use this file except in compliance with the License.
    005// You may obtain a copy of the License at
    006//
    007//     http://www.apache.org/licenses/LICENSE-2.0
    008//
    009// Unless required by applicable law or agreed to in writing, software
    010// distributed under the License is distributed on an "AS IS" BASIS,
    011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    012// See the License for the specific language governing permissions and
    013// limitations under the License.
    014package org.apache.tapestry5.dom;
    015
    016import java.util.Set;
    017
    018import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
    019
    020/**
    021 * Implementation of {@link org.apache.tapestry5.dom.MarkupModel} that correctly handles HTML5 void
    022 * elements. It does not support XHTML5.
    023 */
    024public class Html5MarkupModel extends AbstractMarkupModel
    025{
    026    // http://www.w3.org/TR/html5/syntax.html#void-elements
    027    private final Set<String> VOID_ELEMENTS = CollectionFactory.newSet("area", "base", "br", "col",
    028            "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source",
    029            "track", "wbr");
    030
    031    public Html5MarkupModel()
    032    {
    033        super(false);
    034    }
    035
    036    public Html5MarkupModel(boolean useApostropheForAttributes)
    037    {
    038        super(useApostropheForAttributes);
    039    }
    040
    041    public EndTagStyle getEndTagStyle(String element)
    042    {
    043        return VOID_ELEMENTS.contains(element) ? EndTagStyle.VOID : EndTagStyle.REQUIRE;
    044    }
    045
    046    public boolean isXML()
    047    {
    048        return false;
    049    }
    050
    051}