Updated Branches: refs/heads/master 09bd34c8b -> 0ef56e79b
Rename t5/core/dom:ElementWrapper.attribute() to .attr() Add logic to t5/core/dom to express, on the body element, whether Ajax requests are active or not Fix broken tests Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/0ef56e79 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/0ef56e79 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/0ef56e79 Branch: refs/heads/master Commit: 0ef56e79b254bc730de04586236bbe7f1ea94b62 Parents: 09bd34c Author: Howard M. Lewis Ship <[email protected]> Authored: Mon Nov 25 14:53:55 2013 -0800 Committer: Howard M. Lewis Ship <[email protected]> Committed: Mon Nov 25 14:53:55 2013 -0800 ---------------------------------------------------------------------- .../beanvalidator-validation.coffee | 6 ++-- .../modules/t5/core/ajaxformloop.coffee | 6 ++-- .../META-INF/modules/t5/core/alert.coffee | 6 ++-- .../META-INF/modules/t5/core/console.coffee | 12 +++---- .../META-INF/modules/t5/core/datefield.coffee | 6 ++-- .../META-INF/modules/t5/core/fields.coffee | 10 +++--- .../modules/t5/core/form-fragment.coffee | 4 +-- .../META-INF/modules/t5/core/forms.coffee | 6 ++-- .../META-INF/modules/t5/core/pageinit.coffee | 2 +- .../META-INF/modules/t5/core/select.coffee | 2 +- .../META-INF/modules/t5/core/tree.coffee | 4 +-- .../META-INF/modules/t5/core/validation.coffee | 24 +++++++------- .../META-INF/modules/t5/core/zone.coffee | 8 ++--- .../org/apache/tapestry5/t5-core-dom.coffee | 34 ++++++++++++++++++-- .../apache/tapestry5/test/SeleniumTestCase.java | 19 +++++++++-- .../META-INF/modules/t5/core/injected-upload.js | 4 +-- 16 files changed, 97 insertions(+), 56 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0ef56e79/tapestry-beanvalidator/src/main/coffeescript/META-INF/modules/t5/beanvalidator/beanvalidator-validation.coffee ---------------------------------------------------------------------- diff --git a/tapestry-beanvalidator/src/main/coffeescript/META-INF/modules/t5/beanvalidator/beanvalidator-validation.coffee b/tapestry-beanvalidator/src/main/coffeescript/META-INF/modules/t5/beanvalidator/beanvalidator-validation.coffee index 835e24f..c721088 100644 --- a/tapestry-beanvalidator/src/main/coffeescript/META-INF/modules/t5/beanvalidator/beanvalidator-validation.coffee +++ b/tapestry-beanvalidator/src/main/coffeescript/META-INF/modules/t5/beanvalidator/beanvalidator-validation.coffee @@ -22,7 +22,7 @@ define ["underscore", "t5/core/dom", "t5/core/events", "t5/core/utils", "t5/core (_, dom, events, utils) -> rangeValue = (element, attribute, defaultValue) -> - v = element.attribute attribute + v = element.attr attribute if v is null defaultValue else @@ -48,7 +48,7 @@ define ["underscore", "t5/core/dom", "t5/core/events", "t5/core/utils", "t5/core value = value.length unless min <= value <= max - memo.error = (element.attribute "data-range-message") or "RANGE ERROR" + memo.error = (element.attr "data-range-message") or "RANGE ERROR" return false return true @@ -56,7 +56,7 @@ define ["underscore", "t5/core/dom", "t5/core/events", "t5/core/utils", "t5/core dom.onDocument events.field.optional, "[data-optionality=prohibited]", (event, memo) -> unless utils.isBlank memo.value - memo.error = (@attribute "data-prohibited-message") or "PROHIBITED" + memo.error = (@attr "data-prohibited-message") or "PROHIBITED" return false return true http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0ef56e79/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee index 09f6f3b..69025d5 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee @@ -31,11 +31,11 @@ define ["./dom", "./events", "./console", "./ajax"], console.error "Enclosing element for AjaxFormLoop remove row link not found." return false - url = afl.attribute "data-remove-row-url" + url = afl.attr "data-remove-row-url" ajax url, data: - "t:rowvalue": @attribute "data-afl-row-value" + "t:rowvalue": @attr "data-afl-row-value" success: => # The server has removed the row from persistent storage, lets # do the same on the UI. @@ -56,7 +56,7 @@ define ["./dom", "./events", "./console", "./ajax"], insertionPoint = @findParent "[data-afl-behavior=insert-before]" - url = afl.attribute "data-inject-row-url" + url = afl.attr "data-inject-row-url" ajax url, success: (response) => http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0ef56e79/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/alert.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/alert.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/alert.coffee index 2d2da61..1a1bfcd 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/alert.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/alert.coffee @@ -25,7 +25,7 @@ define ["./dom", "./console", "./messages", "./ajax", "underscore", "./bootstrap warn: "alert-warning" error: "alert-danger" - getURL = (container) -> container.attribute "data-dismiss-url" + getURL = (container) -> container.attr "data-dismiss-url" removeAlert = (container, alert) -> alert.remove() @@ -48,7 +48,7 @@ define ["./dom", "./console", "./messages", "./ajax", "underscore", "./bootstrap alert = button.parent() - id = alert.attribute "data-alert-id" + id = alert.attr "data-alert-id" unless id removeAlert container, alert @@ -64,7 +64,7 @@ define ["./dom", "./console", "./messages", "./ajax", "underscore", "./bootstrap <div data-container-type="inner"></div> """ - if (outer.attribute "data-show-dismiss-all") is "true" + if (outer.attr "data-show-dismiss-all") is "true" outer.append """ <div class="pull-right"> <button class="btn btn-xs btn-default" data-action="dismiss-all"> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0ef56e79/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee index 2b52f0b..d57697e 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee @@ -43,7 +43,7 @@ define ["./dom", "underscore", "./bootstrap"], return - consoleAttribute = dom.body.attribute "data-floating-console" + consoleAttribute = dom.body.attr "data-floating-console" forceFloating = (consoleAttribute is "enabled") or (consoleAttribute is "invisible") @@ -92,7 +92,7 @@ define ["./dom", "underscore", "./bootstrap"], messages = floatingConsole.findFirst ".message-container" - floatingConsole.findFirst("[data-action=enable]").attribute "disabled", true + floatingConsole.findFirst("[data-action=enable]").attr "disabled", true floatingConsole.on "click", "[data-action=clear]", -> floatingConsole.hide() @@ -100,8 +100,8 @@ define ["./dom", "underscore", "./bootstrap"], floatingConsole.on "click", "[data-action=disable]", -> - @attribute "disabled", true - floatingConsole.findFirst("[data-action=enable]").attribute "disabled", false + @attr "disabled", true + floatingConsole.findFirst("[data-action=enable]").attr "disabled", false messages.hide() @@ -109,8 +109,8 @@ define ["./dom", "underscore", "./bootstrap"], floatingConsole.on "click", "[data-action=enable]", -> - @attribute "disabled", true - floatingConsole.findFirst("[data-action=disable]").attribute "disabled", false + @attr "disabled", true + floatingConsole.findFirst("[data-action=disable]").attr "disabled", false messages.show() http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0ef56e79/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/datefield.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/datefield.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/datefield.coffee index 20a9782..bb3a6b5 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/datefield.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/datefield.coffee @@ -81,7 +81,7 @@ define ["./dom", "./events", "./messages", "./ajax", "underscore", "./fields"], @field.addClass "ajax-wait" - ajax (@container.attribute "data-parse-url"), + ajax (@container.attr "data-parse-url"), data: input: value onerror: (message) => @@ -131,7 +131,7 @@ define ["./dom", "./events", "./messages", "./ajax", "underscore", "./fields"], @field.addClass "ajax-wait" - ajax (@container.attribute "data-format-url"), + ajax (@container.attr "data-format-url"), data: input: date.getTime() failure: (response, message) => @@ -147,7 +147,7 @@ define ["./dom", "./events", "./messages", "./ajax", "underscore", "./fields"], scan = (root) -> for container in root.find "[data-component-type='core/DateField']" # Hide it from later scans - container.attribute "data-component-type", null + container.attr "data-component-type", null new Controller(container) http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0ef56e79/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/fields.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/fields.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/fields.coffee index 92a48f8..6ae7fcb 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/fields.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/fields.coffee @@ -20,11 +20,11 @@ define ["underscore", "./events", "./dom", "./utils", "./forms"], (_, events, dom, utils) -> ensureFieldId = (field) -> - fieldId = field.attribute "id" + fieldId = field.attr "id" unless fieldId fieldId = _.uniqueId "field" - field.attribute "id", fieldId + field.attr "id", fieldId return fieldId @@ -37,7 +37,7 @@ define ["underscore", "./events", "./dom", "./utils", "./forms"], # # * field - element wrapper for the field findHelpBlocks = (field) -> - fieldId = field.attribute "id" + fieldId = field.attr "id" # When the field has an id (the normal case!), search the body for # the matching help blocks. @@ -63,7 +63,7 @@ define ["underscore", "./events", "./dom", "./utils", "./forms"], block = group.findFirst "[data-presentation=error]" if block - block.attribute "data-error-block-for", fieldId + block.attr "data-error-block-for", fieldId return [block] # Not found, so perhaps it will be created dynamically. @@ -108,7 +108,7 @@ define ["underscore", "./events", "./dom", "./utils", "./forms"], failure = false fieldValue = - if (@attribute "data-value-mode") is "options" + if (@attr "data-value-mode") is "options" collectOptionValues this else @value() http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0ef56e79/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/form-fragment.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/form-fragment.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/form-fragment.coffee index de21428..24c8fd8 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/form-fragment.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/form-fragment.coffee @@ -29,12 +29,12 @@ define ["underscore", "./dom", "./events", "./forms"], _.each fragments, (frag) -> - fragmentId = frag.attribute "id" + fragmentId = frag.attr "id" hidden = frag.findFirst "input[type=hidden][data-for-fragment='#{fragmentId}']" # If found (e.g., not alwaysSubmit), then enable/disable the field. - hidden && hidden.attribute "disabled", not frag.deepVisible() + hidden && hidden.attr "disabled", not frag.deepVisible() # Again, a DOM event to make the FormFragment visible or invisible; this is useful # because of the didShow/didHide events ... but we're really just seeing the evolution http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0ef56e79/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee index d3adb11..c09a716 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee @@ -35,7 +35,7 @@ define ["./events", "./dom", "underscore"], setSubmittingHidden = (form, submitter) -> - mode = submitter.attribute "data-submit-mode" + mode = submitter.attr "data-submit-mode" isCancel = mode is "cancel" if mode and mode isnt "normal" form.meta SKIP_VALIDATION, true @@ -65,7 +65,7 @@ define ["./events", "./dom", "underscore"], fields = form.find "input, select, textarea" _.each fields, (field) -> - return if field.attribute "disabled" + return if field.attr "disabled" type = field.element.type @@ -108,7 +108,7 @@ define ["./events", "./dom", "underscore"], try - if ((@attribute "data-validate") is "submit") and + if ((@attr "data-validate") is "submit") and (not @meta SKIP_VALIDATION) @meta SKIP_VALIDATION, null http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0ef56e79/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/pageinit.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/pageinit.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/pageinit.coffee index bd7f9e6..b72e788 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/pageinit.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/pageinit.coffee @@ -124,7 +124,7 @@ define ["underscore", "./console", "./dom", "./events"], # be ready to go. We set a flag, mostly used by test suites, to ensure that all is ready. # Note that later Ajax requests do not change this attribute, so their timing continues to be tricky. - dom.body.attribute "data-page-initialized", "true" + dom.body.attr "data-page-initialized", "true" exports = _.extend loadLibrariesAndInitialize, # Passed a list of initializers, executes each initializer in order. Due to asynchronous loading http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0ef56e79/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/select.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/select.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/select.coffee index d35b5e1..23c05e2 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/select.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/select.coffee @@ -25,6 +25,6 @@ define ["./events", "./dom", "./zone"], containingZone = zone.findZone this containingZone and containingZone.trigger events.zone.refresh, - url: @attribute "data-update-url" + url: @attr "data-update-url" parameters: "t:selectvalue": @value() http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0ef56e79/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/tree.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/tree.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/tree.coffee index 65ece69..c7d045c 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/tree.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/tree.coffee @@ -28,12 +28,12 @@ define ["./dom", "./ajax", "./zone"], send = (node, action, success) -> container = node.findParent TREE - url = container.attribute "data-tree-action-url" + url = container.attr "data-tree-action-url" ajax url, data: "t:action": action - "t:nodeid": node.attribute NODE_ID + "t:nodeid": node.attr NODE_ID success: success loadChildren = (node) -> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0ef56e79/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/validation.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/validation.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/validation.coffee index 4547c05..9a22686 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/validation.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/validation.coffee @@ -93,13 +93,13 @@ define ["underscore", "./dom", "./events", "./utils", "./messages", "./fields"], memo.translated = result catch e - memo.error = (field.attribute "data-translation-message") or e.message or "ERROR" + memo.error = (field.attr "data-translation-message") or e.message or "ERROR" return false dom.onDocument events.field.optional, "[data-optionality=required]", (event, memo) -> if utils.isBlank memo.value - memo.error = (@attribute "data-required-message") or "REQUIRED" + memo.error = (@attr "data-required-message") or "REQUIRED" dom.onDocument events.field.translate, "[data-translation=numeric]", (event, memo) -> translate this, memo, false @@ -108,31 +108,31 @@ define ["underscore", "./dom", "./events", "./utils", "./messages", "./fields"], translate this, memo, true dom.onDocument events.field.validate, "[data-validate-min-length]", (event, memo) -> - min = parseInt @attribute "data-validate-min-length" + min = parseInt @attr "data-validate-min-length" if memo.translated.length < min - memo.error = (@attribute "data-min-length-message") or "TOO SHORT" + memo.error = (@attr "data-min-length-message") or "TOO SHORT" return false dom.onDocument events.field.validate, "[data-validate-max-length]", (event, memo) -> - max = parseInt @attribute "data-validate-max-length" + max = parseInt @attr "data-validate-max-length" if memo.translated.length > max - memo.error = (@attribute "data-max-length-message") or "TOO LONG" + memo.error = (@attr "data-max-length-message") or "TOO LONG" return false dom.onDocument events.field.validate, "[data-validate-max]", (event, memo) -> - max = parseInt @attribute "data-validate-max" + max = parseInt @attr "data-validate-max" if memo.translated > max - memo.error = (@attribute "data-max-message") or "TOO LARGE" + memo.error = (@attr "data-max-message") or "TOO LARGE" return false dom.onDocument events.field.validate, "[data-validate-min]", (event, memo) -> - min = parseInt @attribute "data-validate-min" + min = parseInt @attr "data-validate-min" if memo.translated < min - memo.error = (@attribute "data-min-message") or "TOO SMALL" + memo.error = (@attr "data-min-message") or "TOO SMALL" return false dom.onDocument events.field.validate, "[data-validate-regexp]", (event, memo) -> @@ -140,11 +140,11 @@ define ["underscore", "./dom", "./events", "./utils", "./messages", "./fields"], # Cache the compiled regular expression. re = @meta REGEXP_META unless re - re = new RegExp(@attribute "data-validate-regexp") + re = new RegExp(@attr "data-validate-regexp") @meta REGEXP_META, re unless re.test memo.translated - memo.error = (@attribute "data-regexp-message") or "INVALID" + memo.error = (@attr "data-regexp-message") or "INVALID" return false # Export the number parser, just to be nice (and to support some testing). http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0ef56e79/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee index 3ec463b..08696ae 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee @@ -32,7 +32,7 @@ define ["./dom", "./events", "./ajax", "./console", "./forms", "underscore"], # # * element - starting point for determining zone findZone = (element) -> - zoneId = element.attribute "data-update-zone" + zoneId = element.attr "data-update-zone" if zoneId is "^" zone = element.findParent "[data-container-type=zone]" @@ -59,7 +59,7 @@ define ["./dom", "./events", "./ajax", "./console", "./forms", "underscore"], zone = findZone element if zone - zone.trigger events.zone.refresh, url: element.attribute "href" + zone.trigger events.zone.refresh, url: element.attr "href" return false @@ -71,7 +71,7 @@ define ["./dom", "./events", "./ajax", "./console", "./forms", "underscore"], formParameters = forms.gatherParameters this zone.trigger events.zone.refresh, - url: (@attribute "action") + url: (@attr "action") parameters: formParameters return false @@ -100,7 +100,7 @@ define ["./dom", "./events", "./ajax", "./console", "./forms", "underscore"], zone = @closest "[data-container-type=zone]" # A Zone inside a form will render some additional parameters to coordinate updates with the Form on the server. - attr = zone.attribute "data-zone-parameters" + attr = zone.attr "data-zone-parameters" parameters = attr and JSON.parse attr http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0ef56e79/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee b/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee index 2cec0cc..58d07e1 100644 --- a/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee +++ b/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee @@ -280,11 +280,11 @@ define ["underscore", "./utils", "./events", "jquery"], # # * name - the attribute to read or update, or an object of keys and values # * value - (optional) the new value for the attribute - attribute: (name, value) -> + attr: (name, value) -> if _.isObject name for attributeName, value of name - @attribute attributeName, value + @attr attributeName, value return this @@ -666,6 +666,18 @@ define ["underscore", "./utils", "./events", "jquery"], @res.getHeader name #endif + # Used to track how many active Ajax requests are currently in-process. This is incremented + # when an Ajax request is started, and decremented when an Ajax request completes or fails. + # The body attribute `data-ajax-active` is set to "true" or "false" whenever the + # count changes. This only applies to Ajax requests that are filtered through the t5/core/dom API; + # other libraries (including RequireJS) which bypass this API are not counted. + + activeAjaxCount = 0 + + adjustAjaxCount = (delta) -> + activeAjaxCount += delta + + exports.body.attr "data-ajax-active", (activeAjaxCount > 0) # Performs an asynchronous Ajax request, invoking callbacks when it completes. # @@ -694,6 +706,8 @@ define ["underscore", "./utils", "./events", "jquery"], data: options.data # jQuery doesn't have the equivalent of Protoype's onException error: (jqXHR, textStatus, errorThrown) -> + adjustAjaxCount -1 + return if textStatus is "abort" message = "Request to #{url} failed with status #{textStatus}" text = jqXHR.statusText @@ -710,8 +724,13 @@ define ["underscore", "./utils", "./events", "jquery"], success: (data, textStatus, jqXHR) -> + adjustAjaxCount -1 + options.success and options.success(new ResponseWrapper jqXHR, data) return + + adjustAjaxCount +1 + new RequestWrapper jqxhr #elseif prototype finalOptions = @@ -719,6 +738,9 @@ define ["underscore", "./utils", "./events", "jquery"], contentType: options.contentType or "application/x-www-form-urlencoded" parameters: options.data onException: (ajaxRequest, exception) -> + + adjustAjaxCount -1 + if options.exception options.exception exception else @@ -727,6 +749,8 @@ define ["underscore", "./utils", "./events", "jquery"], return onFailure: (response) -> + adjustAjaxCount -1 + message = "Request to #{url} failed with status #{response.getStatus()}" text = response.getStatusText() if not _.isEmpty text @@ -742,6 +766,8 @@ define ["underscore", "./utils", "./events", "jquery"], onSuccess: (response) -> + adjustAjaxCount -1 + # Prototype treats status == 0 as success, even though it may # indicate that the server didn't respond. if (not response.getStatus()) or (not response.request.success()) @@ -753,6 +779,8 @@ define ["underscore", "./utils", "./events", "jquery"], options.success and options.success(new ResponseWrapper response) return + adjustAjaxCount +1 + new RequestWrapper (new Ajax.Request url, finalOptions) #endif @@ -802,7 +830,7 @@ define ["underscore", "./utils", "./events", "jquery"], element = wrapElement document.createElement (elementName or "div") if attributes - element.attribute attributes + element.attr attributes if body element.update body http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0ef56e79/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java ---------------------------------------------------------------------- diff --git a/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java b/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java index 1aee01a..e731d48 100644 --- a/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java +++ b/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java @@ -1470,7 +1470,7 @@ public abstract class SeleniumTestCase extends Assert implements Selenium */ protected void waitForCSSSelectedElementToAppear(String cssSelector) { - String condition = String.format("selenium.browserbot.getCurrentWindow().testSupport.findCSSMatchCount(\"%s\") > 0", cssSelector); + String condition = String.format("window.testSupport.findCSSMatchCount(\"%s\") > 0", cssSelector); waitForCondition(condition, PAGE_LOAD_TIMEOUT); } @@ -1493,7 +1493,7 @@ public abstract class SeleniumTestCase extends Assert implements Selenium /** * Waits for the element to be removed from the DOM. - * + * <p/> * <p/> * This implementation depends on window being extended with testSupport.isNotVisible(). * @@ -1571,7 +1571,20 @@ public abstract class SeleniumTestCase extends Assert implements Selenium */ protected final void waitForAjaxRequestsToComplete(String timeout) { - waitForCondition("selenium.browserbot.getCurrentWindow().Ajax.activeRequestCount == 0", timeout); + for (int i = 0; i < 5; i++) + { + if (i > 0) + { + sleep(100); + } + + if (getAttribute("//body/@data-ajax-active").equals("false")) + { + return; + } + } + + reportAndThrowAssertionError("Body 'data-ajax-active' attribute never reverted to 'false'."); } public Number getCssCount(String str) http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0ef56e79/tapestry-upload/src/main/resources/META-INF/modules/t5/core/injected-upload.js ---------------------------------------------------------------------- diff --git a/tapestry-upload/src/main/resources/META-INF/modules/t5/core/injected-upload.js b/tapestry-upload/src/main/resources/META-INF/modules/t5/core/injected-upload.js index fe3cb95..7a6a71c 100644 --- a/tapestry-upload/src/main/resources/META-INF/modules/t5/core/injected-upload.js +++ b/tapestry-upload/src/main/resources/META-INF/modules/t5/core/injected-upload.js @@ -23,8 +23,8 @@ define(["./dom"], var form = dom(elementId).closest("form"); if (form) { - form.attribute("enctype", "multipart/form-data"); - form.attribute("encoding", "multipart/form-data"); + form.attr("enctype", "multipart/form-data"); + form.attr("encoding", "multipart/form-data"); } } });
