Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit e92fb7f

Browse files
committed
feat(datepicker): remove replace: true usage
- Remove `replace: true` usage BREAKING CHANGE: As a result of removal of `replace: true`, there is the potential that this may break some CSS layout due to the slightly different HTML. Refer to the documentation examples to see the new structure. Closes #5988
1 parent 1a870a3 commit e92fb7f

File tree

8 files changed

+73
-64
lines changed

8 files changed

+73
-64
lines changed

src/datepicker/datepicker.js

+15-6
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
2323
yearRows: 4
2424
})
2525

26-
.controller('UibDatepickerController', ['$scope', '$attrs', '$parse', '$interpolate', '$locale', '$log', 'dateFilter', 'uibDatepickerConfig', '$datepickerLiteralWarning', '$datepickerSuppressError', 'uibDateParser',
27-
function($scope, $attrs, $parse, $interpolate, $locale, $log, dateFilter, datepickerConfig, $datepickerLiteralWarning, $datepickerSuppressError, dateParser) {
26+
.controller('UibDatepickerController', ['$scope', '$element', '$attrs', '$parse', '$interpolate', '$locale', '$log', 'dateFilter', 'uibDatepickerConfig', '$datepickerLiteralWarning', '$datepickerSuppressError', 'uibDateParser',
27+
function($scope, $element, $attrs, $parse, $interpolate, $locale, $log, dateFilter, datepickerConfig, $datepickerLiteralWarning, $datepickerSuppressError, dateParser) {
2828
var self = this,
2929
ngModelCtrl = { $setViewValue: angular.noop }, // nullModelCtrl;
3030
ngModelOptions = {},
3131
watchListeners = [],
3232
optionsUsed = !!$attrs.datepickerOptions;
3333

34+
$element.addClass('uib-datepicker');
35+
$attrs.$set('role', 'application');
36+
3437
if (!$scope.datepickerOptions) {
3538
$scope.datepickerOptions = {};
3639
}
@@ -330,6 +333,12 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
330333
}
331334
};
332335

336+
$element.on('keydown', function(evt) {
337+
$scope.$apply(function() {
338+
$scope.keydown(evt);
339+
});
340+
});
341+
333342
$scope.$on('$destroy', function() {
334343
//Clear all watch listeners on destroy
335344
while (watchListeners.length) {
@@ -572,14 +581,14 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
572581

573582
.directive('uibDatepicker', function() {
574583
return {
575-
replace: true,
576584
templateUrl: function(element, attrs) {
577585
return attrs.templateUrl || 'uib/template/datepicker/datepicker.html';
578586
},
579587
scope: {
580588
datepickerOptions: '=?'
581589
},
582590
require: ['uibDatepicker', '^ngModel'],
591+
restrict: 'A',
583592
controller: 'UibDatepickerController',
584593
controllerAs: 'datepicker',
585594
link: function(scope, element, attrs, ctrls) {
@@ -592,11 +601,11 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
592601

593602
.directive('uibDaypicker', function() {
594603
return {
595-
replace: true,
596604
templateUrl: function(element, attrs) {
597605
return attrs.templateUrl || 'uib/template/datepicker/day.html';
598606
},
599607
require: ['^uibDatepicker', 'uibDaypicker'],
608+
restrict: 'A',
600609
controller: 'UibDaypickerController',
601610
link: function(scope, element, attrs, ctrls) {
602611
var datepickerCtrl = ctrls[0],
@@ -609,11 +618,11 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
609618

610619
.directive('uibMonthpicker', function() {
611620
return {
612-
replace: true,
613621
templateUrl: function(element, attrs) {
614622
return attrs.templateUrl || 'uib/template/datepicker/month.html';
615623
},
616624
require: ['^uibDatepicker', 'uibMonthpicker'],
625+
restrict: 'A',
617626
controller: 'UibMonthpickerController',
618627
link: function(scope, element, attrs, ctrls) {
619628
var datepickerCtrl = ctrls[0],
@@ -626,11 +635,11 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
626635

627636
.directive('uibYearpicker', function() {
628637
return {
629-
replace: true,
630638
templateUrl: function(element, attrs) {
631639
return attrs.templateUrl || 'uib/template/datepicker/year.html';
632640
},
633641
require: ['^uibDatepicker', 'uibYearpicker'],
642+
restrict: 'A',
634643
controller: 'UibYearpickerController',
635644
link: function(scope, element, attrs, ctrls) {
636645
var ctrl = ctrls[0];

src/datepicker/docs/demo.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<h4>Inline</h4>
1717
<div style="display:inline-block; min-height:290px;">
18-
<uib-datepicker ng-model="dt" class="well well-sm" datepicker-options="options"></uib-datepicker>
18+
<div uib-datepicker ng-model="dt" class="well well-sm" datepicker-options="options"></div>
1919
</div>
2020

2121
<hr />

0 commit comments

Comments
 (0)