-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Dialog: Add option to put the dialog title in a header element #2275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
14dc459
c22ba5b
564b793
6f8307d
8f8c2a1
a277562
9238fc0
d4aa8a0
b2f3e72
7b9ea13
478e434
140fa73
f46ff12
6ffab2e
5652776
c70786d
8f583cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,7 @@ $.widget( "ui.dialog", { | |
resizable: true, | ||
show: null, | ||
title: null, | ||
uiDialogTitleTagName: "<span>", | ||
width: 300, | ||
|
||
// Callbacks | ||
|
@@ -437,7 +438,8 @@ $.widget( "ui.dialog", { | |
} | ||
} ); | ||
|
||
uiDialogTitle = $( "<span>" ).uniqueId().prependTo( this.uiDialogTitlebar ); | ||
uiDialogTitle = $( this.options.uiDialogTitleTagName ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Passing user input directly to the jQuery factory is dangerous - apart from obvious abuse when people pass selectors instead of tags here, they can e.g. pass How about introducing an option called That should cover the important use cases here and avoid possible security issues. Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in my initial draft i kept the <> out of the option but thought it would over complicate things so i ended up with the current version. but i agree that your suggested approach would be the better choice. would something like that work?
i am not sure if it would be a clean code wise and i also dont know what the preferred name for the function would be. but the shown snippet is at least already working: the only difference to your suggestion is that the condition is only true between 1 and 6 everything else 0 included becomes a span. and i would also add a few test cases. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That works, but since this logic is quite simple and only used in a single place, it's not necessary to create a function for it, I think. You can just define a local variable with the computed tag name & use it below. Try to keep lines ideally below 80 characters (and definitely below 100), breaking them into multiple lines when necessary. And yes, a few test cases would be needed, when the option was:
Those should be enough, I think. Optionally, instead of testing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok thanks! the suggested changes are in place and the tests are green. |
||
.uniqueId().prependTo( this.uiDialogTitlebar ); | ||
this._addClass( uiDialogTitle, "ui-dialog-title" ); | ||
this._title( uiDialogTitle ); | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.