diff --git a/web-world/impl.rkt b/web-world/impl.rkt index e812357..7075ea2 100644 --- a/web-world/impl.rkt +++ b/web-world/impl.rkt @@ -65,6 +65,7 @@ view-hide view-attr + view-has-attr? update-view-attr remove-view-attr diff --git a/web-world/js-impl.js b/web-world/js-impl.js index ee8c070..f424bb6 100644 --- a/web-world/js-impl.js +++ b/web-world/js-impl.js @@ -216,6 +216,10 @@ return $(this.cursor.node[0]).attr(name); }; + MockView.prototype.hasAttr = function(name) { + return $(this.cursor.node[0]).attr(name) !== undefined; + }; + MockView.prototype.updateAttr = function(name, value) { return this.act( @@ -1923,6 +1927,14 @@ return view.getAttr(name); }); + EXPORTS['view-has-attr?'] = makePrimitiveProcedure( + 'view-has-attr?', + 2, + function(MACHINE) { + var view = checkMockViewOnElement(MACHINE, 'view-has-attr?', 0); + var name = checkSymbolOrString(MACHINE, 'view-has-attr?', 1).toString(); + return view.hasAttr(name); + }); EXPORTS['update-view-attr'] = makePrimitiveProcedure( 'update-view-attr', diff --git a/web-world/racket-impl.rkt b/web-world/racket-impl.rkt index 91598e9..669742d 100644 --- a/web-world/racket-impl.rkt +++ b/web-world/racket-impl.rkt @@ -18,7 +18,7 @@ view-backward view-text update-view-text - view-attr update-view-attr remove-view-attr + view-attr view-has-attr? update-view-attr remove-view-attr view-css update-view-css view-id @@ -148,6 +148,9 @@ (define (view-attr v attr-name) (error 'view-attr "Please run in JavaScript context.")) +(define (view-has-attr? v attr-name) + (error 'view-has-attr? "Please run in JavaScript context.")) + (define (update-view-attr v attr-name value) (error 'update-view-attr "Please run in JavaScript context."))