Permalink
Browse files

[enhance] dom: .contents() binded

  • Loading branch information...
Nicolas Glondu
Nicolas Glondu committed Jan 5, 2012
1 parent 413fc6a commit 198e09982174dc2495796823dc343e0ae1c8341a
Showing with 29 additions and 0 deletions.
  1. +6 −0 opabsl/jsbsl/bslDom.js
  2. +23 −0 stdlib/core/xhtml/dom.opa
View
@@ -97,6 +97,12 @@
return dom.children()
}
+##register select_contents: Dom.private.element -> Dom.private.element
+##args(dom)
+{
+ return dom.contents()
+}
+
##register select_parent: Dom.private.element -> Dom.private.element
##args(dom)
{
View
@@ -123,6 +123,7 @@ type Dom.private.selection =
/ { inside: Dom.private.selection; select: Dom.private.selection }
/ { selector: string } /**A literal CSS selector*/
/ { shallow } /**Select everything at this level*/
+ / { contents } /** Select contents */
/ { concrete: Dom.private.element }/**The concrete client-side representation of a selection.*/
//Note: in the future, we will certainly add new selectors
@@ -243,6 +244,16 @@ Dom = {{
select = {shallow}}
)
+ /**
+ * Select content of a selection
+ * Use this to access the content of an iframe
+ */
+ select_contents(container: dom): dom =
+ (
+ {inside = container
+ select = {contents}}
+ )
+
/**
* Perform a selection using CSS syntax
*/
@@ -448,6 +459,7 @@ Dom = {{
| ~{selector} -> selector
| ~{inside select} -> "{aux(inside)} {aux(select)}"
| {shallow} -> ":parent:children"
+ | {contents} -> ":children"
}}
Rec.aux(dom)
@@ -1617,6 +1629,15 @@ Dom = {{
%% BslDom.select_children %%(parent)
)
+ /**
+ * Select content of a selected [{dom}]
+ * Use this to access the content of an iframe
+ */
+ select_contents(parent:Dom.private.element): Dom.private.element =
+ (
+ %% BslDom.select_contents %%(parent)
+ )
+
/**
* Select all the descendants of a given [{dom}]
*/
@@ -1686,6 +1707,7 @@ Dom = {{
container = top(inside)
depth(container, select)
| ~{concrete} -> concrete
+ | {contents} -> Select.document()
| {shallow} -> Select.document()
depth(container:Dom.private.element, selection:Dom.private.selection):Dom.private.element = match selection with
| { document } -> Select.empty()
@@ -1698,6 +1720,7 @@ Dom = {{
| ~{inside select} ->
container = depth(container, inside)
depth(container, select)
+ | {contents} -> Select.select_contents(container)
| {shallow} -> Select.select_children(container)
}}
Rec.top(selection)

0 comments on commit 198e099

Please sign in to comment.