From 044fac4d77a9c6dad94bdd5708ec0cea0a4b2922 Mon Sep 17 00:00:00 2001 From: Perry Govier Date: Fri, 8 Aug 2014 15:00:19 -0500 Subject: [PATCH] fix(popup): only override prompt input if template includes HTML --- js/angular/service/popup.js | 7 ++++++- test/unit/angular/service/popup.unit.js | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/js/angular/service/popup.js b/js/angular/service/popup.js index 6e37defd34..84a00cc5dd 100644 --- a/js/angular/service/popup.js +++ b/js/angular/service/popup.js @@ -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 = ''+opts.template+''; + delete opts.template; + } return showPopup( extend({ - template: '', scope: scope, buttons: [{ diff --git a/test/unit/angular/service/popup.unit.js b/test/unit/angular/service/popup.unit.js index 0a4e8e6fa1..1d072fa87a 100644 --- a/test/unit/angular/service/popup.unit.js +++ b/test/unit/angular/service/popup.unit.js @@ -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('Tacos!')).toEqual(0); + expect(params[0].template.indexOf(''}); + params = $ionicPopup._createPopup.mostRecentCall.args; + expect(params[0].template.indexOf('')).toEqual(0); + })); }); });