Opened 11 years ago

Closed 10 years ago

#9000 closed enhancement (fixed)

innerText attribute type for dijit's attributeMap; setInnerText method

Reported by: matthw Owned by: bill
Priority: high Milestone: 1.4
Component: Dijit Version: 1.3.0rc2
Keywords: innerText attributeMap dijit attribute dojo.html Cc:
Blocked By: Blocking:

Description

(as requested a separate ticket for this)

It would be nice if you could use dijit's attributeMap magic with text-based setters as well as html-based. This could be added via a new attribute type 'innerText', eg:

attributeMap: {
  title: { node: "titleNode", type: "innerText" }
}

When you're dealing with dynamic or user-input content you'll almost always want to be treating it as text rather than as html... or at least so I've found. So the option would be nice, whether or not it's the default.

It would also be nice to have a reusable 'setInnerText' method in dojo.html or dojo._base.html, which could be used to implement this and elsewhere too. It would save a lot of boilerplate along the lines of:

dojo.html.set(someNode, '');
someNode.appendChild(dojo.doc.createTextNode(text));

Which I see repeated in a lot of dijit code.

(or if preferred this could be implemented as an option to dojo.html.set; in this case it obviously wouldn't work in combination with passing DOM nodes as the content to set)

I'd be happy to make a patch adding this functionality, looks like it should be quite a clean/easy thing to add. Just let me know how you'd prefer it done.

Change History (6)

comment:1 Changed 11 years ago by bill

Component: GeneralDijit
Owner: anonymous deleted

Hi matthw,

Sure a patch would be great if you've signed a CLA, hopefully w/a new little test for it in _Widget-attr.html (which is the extent of attributeMap tests that we have today).

comment:2 Changed 11 years ago by matthw

I haven't done a CLA yet, but should be fine. Is there any process involved to start contributing or do I just fax one over and post the patch on the relevant ticket?

comment:3 Changed 11 years ago by dante

@matthw - just fax/email the signed CLA, and attach the patch. Future patches you can go ahead an add [cla][patch] to the title so it stands out, which will we do for this ticket once the CLA is verified etc. thanks!

comment:4 Changed 10 years ago by bill

Milestone: tbdfuture

comment:5 Changed 10 years ago by bill

Milestone: future1.4
Owner: set to bill
Status: newassigned

comment:6 Changed 10 years ago by bill

Resolution: fixed
Status: assignedclosed

(In [20609]) Add innerText type for attributeMap (similar to innerHTML but for plain text), and use it for Tree labels, to match Tree's 1.3 behavior. Fixes #9000, #10128, refs #9230 !strict.

Note: See TracTickets for help on using tickets.