diff --git a/tests/more-tests/view.expected b/tests/more-tests/view.expected index ea8ddd6..f64d296 100644 --- a/tests/more-tests/view.expected +++ b/tests/more-tests/view.expected @@ -2,4 +2,8 @@ "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"))))) \ No newline at end of file +"baz" +(html (head) (body (p (@ (class "baz"))))) +"line-through" +"underline" +(html (head) (body (p (@ (style "text-decoration: underline; "))))) diff --git a/tests/more-tests/view.rkt b/tests/more-tests/view.rkt index 4934ee4..6a69440 100644 --- a/tests/more-tests/view.rkt +++ b/tests/more-tests/view.rkt @@ -18,6 +18,15 @@ (view->xexp (view-up (view-up updated-new-view))) + +(define (my-view-top v) + (cond [(view-up? v) + (my-view-top (view-up v))] + [else + v])) + + +;; Trying attribute editing (view-attr (view-down (view-right (view-down @@ -25,12 +34,14 @@ (body (p (@ (class "blah")))))))))) "class") - -(define (my-view-top v) - (cond [(view-up? v) - (my-view-top (view-up v))] - [else - v])) +(view-attr (update-view-attr (view-down + (view-right + (view-down + (->view (xexp->dom `(html (head) + (body (p (@ (class "blah")))))))))) + "class" + "baz") + "class") (view->xexp (my-view-top @@ -41,3 +52,32 @@ (body (p (@ (class "blah")))))))))) "class" "baz"))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(view-css (view-down + (view-right + (view-down + (->view (xexp->dom `(html (head) + (body (p (@ (style "text-decoration: line-through")))))))))) + "text-decoration") + +(view-css (update-view-css (view-down + (view-right + (view-down + (->view (xexp->dom `(html (head) + (body (p (@ (style "text-decoration: line-through")))))))))) + "text-decoration" + "underline") + "text-decoration") + +(view->xexp + (my-view-top + (update-view-css (view-down + (view-right + (view-down + (->view (xexp->dom `(html (head) + (body (p (@ (style "text-decoration: line-through")))))))))) + "text-decoration" + "underline"))) diff --git a/web-world/js-impl.js b/web-world/js-impl.js index 43f24a2..2124465 100644 --- a/web-world/js-impl.js +++ b/web-world/js-impl.js @@ -211,7 +211,7 @@ MockView.prototype.updateAttr = function(name, value) { return this.act( function(cursor) { - return cursor.replaceNode([$(cursor.node[0].cloneNode(true)) + return cursor.replaceNode([$(cursor.node[0].cloneNode(false)) .attr(name, value).get(0)] .concat(cursor.node.slice(1))); }, @@ -235,7 +235,9 @@ MockView.prototype.updateCss = function(name, value) { return this.act( function(cursor) { - return cursor.replaceNode([$(cursor.node[0].cloneNode(true)) + console.log($(cursor.node[0].cloneNode(false)) + .css(name, value).get(0)); + return cursor.replaceNode([$(cursor.node[0].cloneNode(false)) .css(name, value).get(0)] .concat(cursor.node.slice(1))); }, @@ -259,7 +261,7 @@ MockView.prototype.updateFormValue = function(value) { return this.act( function(cursor) { - return cursor.replaceNode([$(cursor.node[0].cloneNode(true)) + return cursor.replaceNode([$(cursor.node[0].cloneNode(false)) .val(value).get(0)] .concat(cursor.node.slice(1))); }, @@ -367,7 +369,7 @@ MockView.prototype.show = function() { return this.act( function(cursor) { - return cursor.replaceNode([$(cursor.node[0].cloneNode(true)) + return cursor.replaceNode([$(cursor.node[0].cloneNode(false)) .show().get(0)] .concat(cursor.node.slice(1))); }, @@ -381,7 +383,7 @@ MockView.prototype.hide = function() { return this.act( function(cursor) { - return cursor.replaceNode([$(cursor.node[0].cloneNode(true)) + return cursor.replaceNode([$(cursor.node[0].cloneNode(false)) .hide().get(0)] .concat(cursor.node.slice(1))); }, @@ -423,9 +425,9 @@ while (cursor.canRight()) { cursor = cursor.right(); } - return cursor.insertRight([domNode.cloneNode(true)]); + return cursor.insertRight(domNodeToArrayTree(domNode)); } else { - return cursor.insertDown([domNode.cloneNode(true)]); + return cursor.insertDown(domNodeToArrayTree(domNode)); } }, function(eventHandlers) { return eventHandlers; },