Skip to content

Commit ed079da

Browse files
Merge pull request #143 from angular/master
Update upstream
2 parents 74df9c7 + 78b9f61 commit ed079da

File tree

4 files changed

+85
-6
lines changed

4 files changed

+85
-6
lines changed

karma-shared.conf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ module.exports = function(config, specificOptions) {
114114
base: 'SauceLabs',
115115
browserName: 'iphone',
116116
platform: 'OS X 10.12',
117-
version: '11.3'
117+
version: '11.2'
118118
},
119119

120120
'BS_Chrome': {

src/ng/compile.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -2575,7 +2575,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
25752575

25762576
// We have transclusion slots,
25772577
// collect them up, compile them and store their transclusion functions
2578-
$template = [];
2578+
$template = window.document.createDocumentFragment();
25792579

25802580
var slotMap = createMap();
25812581
var filledSlots = createMap();
@@ -2603,10 +2603,10 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
26032603
var slotName = slotMap[directiveNormalize(nodeName_(node))];
26042604
if (slotName) {
26052605
filledSlots[slotName] = true;
2606-
slots[slotName] = slots[slotName] || [];
2607-
slots[slotName].push(node);
2606+
slots[slotName] = slots[slotName] || window.document.createDocumentFragment();
2607+
slots[slotName].appendChild(node);
26082608
} else {
2609-
$template.push(node);
2609+
$template.appendChild(node);
26102610
}
26112611
});
26122612

@@ -2620,9 +2620,11 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
26202620
for (var slotName in slots) {
26212621
if (slots[slotName]) {
26222622
// Only define a transclusion function if the slot was filled
2623-
slots[slotName] = compilationGenerator(mightHaveMultipleTransclusionError, slots[slotName], transcludeFn);
2623+
slots[slotName] = compilationGenerator(mightHaveMultipleTransclusionError, slots[slotName].childNodes, transcludeFn);
26242624
}
26252625
}
2626+
2627+
$template = $template.childNodes;
26262628
}
26272629

26282630
$compileNode.empty(); // clear contents

src/ngMock/angular-mocks.js

+33
Original file line numberDiff line numberDiff line change
@@ -2756,6 +2756,39 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
27562756
* control how a matched request is handled. You can save this object for later use and invoke
27572757
* `respond` or `passThrough` again in order to change how a matched request is handled.
27582758
*/
2759+
/**
2760+
* @ngdoc method
2761+
* @name $httpBackend#matchLatestDefinition
2762+
* @module ngMockE2E
2763+
* @description
2764+
* This method can be used to change which mocked responses `$httpBackend` returns, when defining
2765+
* them with {@link ngMock.$httpBackend#when $httpBackend.when()} (and shortcut methods).
2766+
* By default, `$httpBackend` returns the first definition that matches. When setting
2767+
* `$http.matchLatestDefinition(true)`, it will use the last response that matches, i.e. the
2768+
* one that was added last.
2769+
*
2770+
* ```js
2771+
* hb.when('GET', '/url1').respond(200, 'content', {});
2772+
* hb.when('GET', '/url1').respond(201, 'another', {});
2773+
* hb('GET', '/url1'); // receives "content"
2774+
*
2775+
* $http.matchLatestDefinition(true)
2776+
* hb('GET', '/url1'); // receives "another"
2777+
*
2778+
* hb.when('GET', '/url1').respond(201, 'onemore', {});
2779+
* hb('GET', '/url1'); // receives "onemore"
2780+
* ```
2781+
*
2782+
* This is useful if a you have a default response that is overriden inside specific tests.
2783+
*
2784+
* Note that different from config methods on providers, `matchLatestDefinition()` can be changed
2785+
* even when the application is already running.
2786+
*
2787+
* @param {Boolean=} value value to set, either `true` or `false`. Default is `false`.
2788+
* If omitted, it will return the current value.
2789+
* @return {$httpBackend|Boolean} self when used as a setter, and the current value when used
2790+
* as a getter
2791+
*/
27592792
angular.mock.e2e = {};
27602793
angular.mock.e2e.$httpBackendDecorator =
27612794
['$rootScope', '$timeout', '$delegate', '$browser', createHttpBackendMock];

test/ng/compileSpec.js

+44
Original file line numberDiff line numberDiff line change
@@ -8843,6 +8843,50 @@ describe('$compile', function() {
88438843
});
88448844
});
88458845

8846+
8847+
it('should correctly handle multi-element directives', function() {
8848+
module(function() {
8849+
directive('foo', valueFn({
8850+
template: '[<div ng-transclude></div>]',
8851+
transclude: true
8852+
}));
8853+
directive('bar', valueFn({
8854+
template: '[<div ng-transclude="header"></div>|<div ng-transclude="footer"></div>]',
8855+
transclude: {
8856+
header: 'header',
8857+
footer: 'footer'
8858+
}
8859+
}));
8860+
});
8861+
8862+
inject(function($compile, $rootScope) {
8863+
var tmplWithFoo =
8864+
'<foo>' +
8865+
'<div ng-if-start="true">Hello, </div>' +
8866+
'<div ng-if-end>world!</div>' +
8867+
'</foo>';
8868+
var tmplWithBar =
8869+
'<bar>' +
8870+
'<header ng-if-start="true">This is a </header>' +
8871+
'<header ng-if-end>header!</header>' +
8872+
'<footer ng-if-start="true">This is a </footer>' +
8873+
'<footer ng-if-end>footer!</footer>' +
8874+
'</bar>';
8875+
8876+
var elem1 = $compile(tmplWithFoo)($rootScope);
8877+
var elem2 = $compile(tmplWithBar)($rootScope);
8878+
8879+
$rootScope.$digest();
8880+
8881+
expect(elem1.text()).toBe('[Hello, world!]');
8882+
expect(elem2.text()).toBe('[This is a header!|This is a footer!]');
8883+
8884+
dealoc(elem1);
8885+
dealoc(elem2);
8886+
});
8887+
});
8888+
8889+
88468890
//see issue https://github.com/angular/angular.js/issues/12936
88478891
it('should use the proper scope when it is on the root element of a replaced directive template', function() {
88488892
module(function() {

0 commit comments

Comments
 (0)