Opened 9 years ago

Closed 9 years ago

#17390 closed defect (fixed)

ValidationTextBox constructor sets constraints to {}

Reported by: patrickzope Owned by: Douglas Hays
Priority: undecided Milestone: 1.10
Component: Dijit - Form Version: 1.9.1
Keywords: Cc:
Blocked By: Blocking:


The ValidationTextBox?'s constructor sets the constraints attribute to {}, a value which is also defined as an attribute in the call to dojo/_base/declare.

This makes it impossible to declare subclasses of ValidationTextBox? that simply set the constraints and pattern attributes like so:

declare(ValidationTextBox, {
  constraints: {allowCruft: false},
  pattern: dojox.validate.regexp.emailAddress

Attachments (3)

patch.txt (877 bytes) - added by sunxcint 9 years ago.
Basic.js (2.0 KB) - added by sunxcint 9 years ago.
test_validation_constraints.html (2.6 KB) - added by sunxcint 9 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 9 years ago by dylan

Component: GeneralDijit - Form
Milestone: tbd1.9.2
Resolution: fixed
Status: newclosed

In order to preserve getters/setters, I think you really want something like this (you really don't want to set constraints on the prototype, you want to set them on the constructor)

declare(ValidationTextBox, {
  pattern: dojox.validate.regexp.emailAddress,
  constructor: function () {
    this.constraints = { allowCruft: false };
Last edited 9 years ago by ben hockey (previous) (diff)

comment:2 Changed 9 years ago by bill

Resolution: fixed
Status: closedreopened

That's the workaround, although it would be better to be able to set constraints on the prototype.

That weird code is from 8c26273a5ed64033fddfdb1035bff435fe421bab and [7558] and [10412], as a workaround to the problem that dojo.regexp writes directly to the object passed in.

In any case it's not something that we fixed in 1.9.2, so we should either mark this as wontfix or actually fix it.

Changed 9 years ago by sunxcint

Attachment: patch.txt added

comment:3 Changed 9 years ago by sunxcint

I think there are two folds for this defect

  1. Constraints can be set on the prototype;
  2. Constraints can be modified in one instance independently from other instances.

Please see my fix in the attached patch.txt.

comment:4 Changed 9 years ago by bill

Milestone: 1.9.2tbd
Owner: set to Douglas Hays
Status: reopenedassigned

Looks reasonable although we need an automated test case before checking it in.

Changed 9 years ago by sunxcint

Attachment: Basic.js added

comment:5 Changed 9 years ago by sunxcint

Basic.js is a test case for my patch. (I did want to modify its name to be testcase.js but I did not figure out how to do it. Sorry!)

Changed 9 years ago by sunxcint

comment:6 Changed 9 years ago by Douglas Hays

Milestone: tbd1.10

comment:7 Changed 9 years ago by doughays-dojo <[email protected]…>

Resolution: fixed
Status: assignedclosed

In 46ea1d899811988d545bf5974a5326e53fa5e484/dijit:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 
Note: See TracTickets for help on using tickets.