mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(popup): only override prompt input if template includes HTML
This commit is contained in:
7
js/angular/service/popup.js
vendored
7
js/angular/service/popup.js
vendored
@@ -464,8 +464,13 @@ function($ionicTemplateLoader, $ionicBackdrop, $q, $timeout, $rootScope, $docume
|
||||
function showPrompt(opts) {
|
||||
var scope = $rootScope.$new(true);
|
||||
scope.data = {};
|
||||
var text = '';
|
||||
if(opts.template && /<[a-z][\s\S]*>/i.test(opts.template) === false){
|
||||
text = '<span>'+opts.template+'</span>';
|
||||
delete opts.template;
|
||||
}
|
||||
return showPopup( extend({
|
||||
template: '<input ng-model="data.response" type="' + (opts.inputType || 'text') +
|
||||
template: text+'<input ng-model="data.response" type="' + (opts.inputType || 'text') +
|
||||
'" placeholder="' + (opts.inputPlaceholder || '') + '">',
|
||||
scope: scope,
|
||||
buttons: [{
|
||||
|
||||
@@ -277,5 +277,16 @@ describe('$ionicPopup service', function() {
|
||||
$timeout.flush();
|
||||
expect($ionicBackdrop.release).toHaveBeenCalled();
|
||||
}));
|
||||
it('template should only overwrite prompt input if it includes html', inject(function($timeout) {
|
||||
spyOn($ionicPopup, '_createPopup');
|
||||
$ionicPopup.prompt({template: "Tacos!"});
|
||||
params = $ionicPopup._createPopup.mostRecentCall.args;
|
||||
expect(params[0].template.indexOf('<span>Tacos!</span>')).toEqual(0);
|
||||
expect(params[0].template.indexOf('<input')).toBeGreaterThan(6);
|
||||
|
||||
$ionicPopup.prompt({template: '<input type="email" />'});
|
||||
params = $ionicPopup._createPopup.mostRecentCall.args;
|
||||
expect(params[0].template.indexOf('<input type="email" />')).toEqual(0);
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user