Return-Path: X-Original-To: apmail-myfaces-commits-archive@www.apache.org Delivered-To: apmail-myfaces-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D14FE6771 for ; Tue, 28 Jun 2011 12:05:20 +0000 (UTC) Received: (qmail 95948 invoked by uid 500); 28 Jun 2011 12:05:20 -0000 Delivered-To: apmail-myfaces-commits-archive@myfaces.apache.org Received: (qmail 95833 invoked by uid 500); 28 Jun 2011 12:05:19 -0000 Mailing-List: contact commits-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Development" Delivered-To: mailing list commits@myfaces.apache.org Received: (qmail 95826 invoked by uid 99); 28 Jun 2011 12:05:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jun 2011 12:05:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jun 2011 12:05:16 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 07BB52388980 for ; Tue, 28 Jun 2011 12:04:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1140545 - in /myfaces/tobago/trunk/tobago-core/src: main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java test/java/org/apache/myfaces/tobago/renderkit/html/DataAttributesUnitTest.java Date: Tue, 28 Jun 2011 12:04:54 -0000 To: commits@myfaces.apache.org From: lofwyr@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110628120455.07BB52388980@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: lofwyr Date: Tue Jun 28 12:04:54 2011 New Revision: 1140545 URL: http://svn.apache.org/viewvc?rev=1140545&view=rev Log: TOBAGO-1004: Using custom attributes for HTML in a HTML5 compliant way Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/html/DataAttributesUnitTest.java Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java?rev=1140545&view=auto ============================================================================== --- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java (added) +++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java Tue Jun 28 12:04:54 2011 @@ -0,0 +1,31 @@ +package org.apache.myfaces.tobago.renderkit.html; + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Custom data attributes. + * These attributes may transport data to DOM which are not standardized. + * The format is "data-tobago-*" which is conform to HTML 5, but also works in older browsers. + */ +public final class DataAttributes { + + /** + * Custom disabled attribute. Use for element, that don't have the disabled attribute. + */ + public static final String DISABLED = "data-tobago-disabled"; +} Added: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/html/DataAttributesUnitTest.java URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/html/DataAttributesUnitTest.java?rev=1140545&view=auto ============================================================================== --- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/html/DataAttributesUnitTest.java (added) +++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/html/DataAttributesUnitTest.java Tue Jun 28 12:04:54 2011 @@ -0,0 +1,40 @@ +package org.apache.myfaces.tobago.renderkit.html; + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.junit.Assert; +import org.junit.Test; + +import java.lang.reflect.Field; + +public class DataAttributesUnitTest { + + public static final String PREFIX = "data-tobago-"; + + @Test + public void testAttributeNames() throws IllegalAccessException { + for (Field field : DataAttributes.class.getFields()) { + String value = (String) field.get(null); + Assert.assertTrue("Prefix check: value='" + value + "'", value.startsWith(PREFIX)); + String extension = value.substring(PREFIX.length()); + Assert.assertTrue("Regexp check: extension='" + extension + "'", extension.matches("[a-z]+(-[a-z]+)*")); + String fieldExtension = field.getName().toLowerCase().replace('_', '-'); + Assert.assertEquals(fieldExtension, extension); + } + } +}