myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
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 GMT
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);
+    }
+  }
+}



Mime
View raw message