Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#15018 closed defect (fixed)

aspect.after discard "false" return values

Reported by: ID Owned by: Kris Zyp
Priority: undecided Milestone: 1.8
Component: Events Version: 1.7.2
Keywords: Cc:
Blocked By: Blocking:

Description

In the test below the submit should be blocked by the blockSubmit function but it doesn't work. The error lies within aspect.after which only replace the return value if it is true-ish instead of testing it being different then undefined.

<html>
	<head>
		<script src="dojo/dojo.js" data-dojo-config="async: true"></script>
		<script>
			require(["dojo/parser", "dijit/registry", "dijit/form/Form", "dojo/domReady!"], function(parser, registry){
				var blockSubmit = function() {
					debugger;
					// Should block the submit action of the form
					return false;
				}
				parser.parse();
				var form = registry.byId("myForm");
				form.on("submit", blockSubmit);
			});
		</script>
	</head>
	<body>
		<form data-dojo-type="dijit.form.Form" id="myForm">
			<input type="submit" value="Click me" />
		</form>
		<script>document.write("<span>Random number: "+Math.round(Math.random()*10000)+"</span>");</script>
	</body>
</html>

I've attached a patch which solve this problem.

Attachments (1)

dojo_aspect.patch (936 bytes) - added by ID 8 years ago.
Test for different than undefined instead of true-ish

Download all attachments as: .zip

Change History (3)

Changed 8 years ago by ID

Attachment: dojo_aspect.patch added

Test for different than undefined instead of true-ish

comment:1 Changed 7 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

In [29001]:

Change return value when after advice returns any (non-undefined) value, fixes #15018 !strict

comment:2 Changed 7 years ago by bill

Milestone: tbd1.8
Note: See TracTickets for help on using tickets.