adding some test cases for navigating, editing the tree

This commit is contained in:
Danny Yoo 2011-09-07 16:47:37 -04:00
parent d19e8562ac
commit 901b4d9305
3 changed files with 28 additions and 4 deletions

View File

@ -1,3 +1,5 @@
"" ""
"some text" "some text"
(html (head) (body (p "hello world, this is a test") (div (@ (id "a div")) "some text"))) (html (head) (body (p "hello world, this is a test") (div (@ (id "a div")) "some text")))
"blah"
(html (head) (body (p (@ (class "baz")))))

View File

@ -16,6 +16,28 @@
(view-text updated-new-view) ;; should be "some text" (view-text updated-new-view) ;; should be "some text"
(view->xexp (view-up (view-up updated-new-view))) (view->xexp (view-up (view-up updated-new-view)))
;; should be:
; (html (head) (body (p "hello world, this is a test")
; (div (@ (id "a div")) "some text"))) (view-attr (view-down
(view-right
(view-down
(->view (xexp->dom `(html (head)
(body (p (@ (class "blah"))))))))))
"class")
(define (my-view-top v)
(cond [(view-up? v)
(my-view-top (view-up v))]
[else
v]))
(view->xexp
(my-view-top
(update-view-attr (view-down
(view-right
(view-down
(->view (xexp->dom `(html (head)
(body (p (@ (class "blah"))))))))))
"class"
"baz")))

View File

@ -194,7 +194,7 @@
return this.act( return this.act(
function(cursor) { function(cursor) {
return cursor.replaceNode([cursor.node[0]] return cursor.replaceNode([cursor.node[0]]
.concat([document.createTextNode(text)])); .concat([[document.createTextNode(text)]]));
}, },
function(eventHandlers) { return eventHandlers; }, function(eventHandlers) { return eventHandlers; },
function(view) { function(view) {