Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added test RefinementsTester and incorporated into StaxTestSuite

  • Loading branch information...
commit 885e0c5c1dee9ab2942135a674605cc151086013 1 parent bc66e54
Paul De Goes pauldegoes authored
30 src/main/haxe/js/dom/Refinements.hx
View
@@ -21,18 +21,30 @@ import Dom;
using PreludeExtensions;
class Refinements {
- public static inline function iframe(e: HTMLElement): HTMLIFrameElement {
+ public static inline function asIframe(e: HTMLElement): HTMLIFrameElement {
return iframeOption(e).get();
}
- public static inline function script(e: HTMLElement): HTMLScriptElement {
+ public static inline function asScript(e: HTMLElement): HTMLScriptElement {
return scriptOption(e).get();
}
- public static inline function div(e: HTMLElement): HTMLDivElement {
+ public static inline function asDiv(e: HTMLElement): HTMLDivElement {
return divOption(e).get();
}
+ public static inline function asForm(e: HTMLElement): HTMLFormElement {
+ return formOption(e).get();
+ }
+
+ public static inline function asBody(e: HTMLElement): HTMLBodyElement {
+ return bodyOption(e).get();
+ }
+
+ public static inline function asStyle(e: HTMLElement): HTMLStyleElement {
+ return styleOption(e).get();
+ }
+
// ************************
public static inline function iframeOption(e: HTMLElement): Option<HTMLIFrameElement> {
@@ -46,4 +58,16 @@ class Refinements {
public static inline function divOption(e: HTMLElement): Option<HTMLDivElement> {
return if (e.nodeName == 'DIV') Some(cast e); else None;
}
+
+ public static inline function formOption(e: HTMLElement): Option<HTMLFormElement> {
+ return if (e.nodeName == 'FORM') Some(cast e); else None;
+ }
+
+ public static inline function bodyOption(e: HTMLElement): Option<HTMLBodyElement> {
+ return if (e.nodeName == 'BODY') Some(cast e); else None;
+ }
+
+ public static inline function styleOption(e: HTMLElement): Option<HTMLStyleElement> {
+ return if (e.nodeName == 'STYLE') Some(cast e); else None;
+ }
}
19 src/test/haxe/DomTester.hx
View
@@ -2038,24 +2038,7 @@ class DomTest extends TestCase {
verifyThatPropertiesExist(imgData, imgDataProperties);
verifyThatPropertiesExist(pixArray, pixArrayProperties);
}
-
- private function testThatRefinementsIFrameOptionWorks(): Void {
- var iframe = _doc.getElementsByTagName('iframe')[0];
-
- assertEquals("IFRAME", iframe.iframe().nodeName);
- }
-
- private function testThatRefinementsScriptOptionWorks(): Void {
- var script = _doc.getElementsByTagName('script')[0];
-
- assertEquals("SCRIPT", script.script().nodeName);
- }
-
- private function testThatRefinementsDIVOptionWorks(): Void {
- var div = _doc.getElementsByTagName('div')[0];
-
- assertEquals("DIV", div.div().nodeName);
- }
+
2  src/test/haxe/StaxTestSuite.hx
View
@@ -40,6 +40,7 @@ import haxe.framework.Injector;
#if js
import haxe.io.http.HttpStringTestCase;
+import js.dom.RefinementsTester;
import js.io.IFrameIOTestCase;
import haxe.io.http.HttpJValueJsonpTestCase;
#end
@@ -68,6 +69,7 @@ class StaxTestSuite {
, new HttpStringTestCase() // This one should be cross-platform, eventually
, new IFrameIOTestCase()
, new HttpJValueJsonpTestCase()
+ , new RefinementsTestCase()
#end
]);
2  test.html
View
@@ -2,10 +2,12 @@
<html>
<head>
<title></title>
+ <style type="text/css"></style>
</head>
<body>
<div id="haxe:trace"></div>
<script type="text/javascript" src="test.js"></script>
+ <form></form>
</body>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.