Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
fix(util): improve parse logic in supplant()
Browse files Browse the repository at this point in the history
Fixes #4511.
  • Loading branch information
ThomasBurleson committed Sep 10, 2015
1 parent 562e41a commit 81b633c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/util/util.js
Expand Up @@ -298,7 +298,9 @@ function UtilFactory($document, $timeout, $compile, $rootScope, $$mdAnimate, $in
r = values;
try {
for (var s in p) {
r = r[p[s]];
if (p.hasOwnProperty(s) ) {
r = r[p[s]];
}
}
} catch (e) {
r = a;
Expand Down
18 changes: 18 additions & 0 deletions src/core/util/util.spec.js
Expand Up @@ -46,6 +46,24 @@ describe('util', function() {

});

describe('supplant', function() {

it('should replace with HTML arguments', inject(function($mdUtil) {
var param1 = "", param2 = '' +
'<md-content>' +
' <md-option ng-repeat="value in values" value="{{value}}">' +
' {{value}} ' +
' </md-option> ' +
'</md-content> ';
var template = '<div class="md-select-menu-container"><md-select-menu {0}>{1}</md-select-menu></div>';
var results = $mdUtil.supplant(template,[param1, param2]);
var segment = '<md-select-menu >'; // After supplant() part of the result should be...

expect( results.indexOf(segment) > -1 ).toBe(true);

}));

});

describe('findFocusTarget', function() {

Expand Down

1 comment on commit 81b633c

@ThomasBurleson
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix allows 3rd-party libraries to modify the Array.prototype. See issue #4511.

Please sign in to comment.