Closed Bug 723431 Opened 14 years ago Closed 14 years ago

DOMTemplate should allow customisation of display of null/undefined values

Categories

(DevTools :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 15

People

(Reporter: jwalker, Assigned: jwalker)

References

Details

Attachments

(1 file, 2 obsolete files)

Currently: <div id=a>${foo}</div> + domtemplate('a', { foo: null }); V <div id=a>null</div> This is good for debugging, but it's annoying - frequently you want null/undefined to show up as an empty string. We should add an option so: <div id=a>${foo}</div> + domtemplate('a', { foo: null }, { blankNullUndefined: true }); V <div id=a></div>
Blocks: 724819
Assignee: nobody → jwalker
Status: NEW → ASSIGNED
Attached patch upload 1 (obsolete) — Splinter Review
Attachment #594990 - Flags: review?(dcamp)
If you'd like to see the extra parts cut-up github style: https://github.com/campd/gcli/pull/14
Comment on attachment 594990 [details] [diff] [review] upload 1 Review of attachment 594990 [details] [diff] [review]: ----------------------------------------------------------------- ::: browser/devtools/shared/Templater.jsm @@ +54,5 @@ > * @param node A DOM element or string referring to an element's id > * @param data Data to use in filling out the template > * @param options Options to customize the template processing. One of: > * - allowEval: boolean (default false) Basic template interpolations are > + * either property paths (e.g. ${a.b.c.d}), however if allowEval=true then we This isn't new, but that 'either' seems to be missing an 'or'.
Attachment #594990 - Flags: review?(dcamp) → review+
Attached patch upload 2 (obsolete) — Splinter Review
<blush> I forgot to do the null/undefined processing on attribute values. See here for the fix: } else { // Replace references in all other attributes var newValue = value.replace(this._templateRegion, function(path) { - return this._envEval(path.slice(2, -1), data, value); + var insert = this._envEval(path.slice(2, -1), data, value); + if (this.options.blankNullUndefined && insert == null) { + insert = ''; + } + return insert; }.bind(this)); // Remove '_' prefix of attribute names so the DOM won't try // to use them before we've processed the template Also this fixes your note about the either/or in the doc-comment, and adds tests for the above change.
Attachment #594990 - Attachment is obsolete: true
Attachment #596797 - Flags: review?(dcamp)
Attachment #596797 - Flags: review?(dcamp) → review+
No longer blocks: 724819
Blocks: 736831
Attached patch upload 3Splinter Review
You reviewed this ages ago, but I never committed. I re-pushed to try (https://tbpl.mozilla.org/?tree=Try&pusher=jwalker@mozilla.com) and rolled in the one char fix to bug 736831, which you reviewed yesterday: https://github.com/joewalker/gcli/commit/d4d93245aff9ad3cdd81733696443bd8a416844d and https://github.com/campd/gcli/pull/27#issuecomment-4883212 It seems like a no-brainer that I can commit this, but I'm just checking.
Attachment #596797 - Attachment is obsolete: true
Attachment #611850 - Flags: review?(dcamp)
Attachment #611850 - Flags: review?(dcamp) → review+
Whiteboard: [fixed-in-fx-team]
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 15
This patch was in a range which caused a Ts regression, so I backed out the whole range: https://hg.mozilla.org/mozilla-central/rev/24a6a53c714a Please reland after investigating and fixing the regression.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Status: REOPENED → RESOLVED
Closed: 14 years ago14 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: