MCPcopy Index your code
hub / github.com/angular-ui/ui-grid / mergeTemplateAttributes

Function mergeTemplateAttributes

lib/test/angular/1.7.0/angular.js:10289–10321  ·  view source on GitHub ↗

* When the element is replaced with HTML template then the new attributes * on the template need to be merged with the existing attributes in the DOM. * The desired effect is to have both of the attributes present. * * @param {object} dst destination attributes (original DOM)

(dst, src)

Source from the content-addressed store, hash-verified

10287 * @param {object} src source attributes (from the directive template)
10288 */
10289 function mergeTemplateAttributes(dst, src) {
10290 var srcAttr = src.$attr,
10291 dstAttr = dst.$attr;
10292
10293 // reapply the old attributes to the new element
10294 forEach(dst, function(value, key) {
10295 if (key.charAt(0) !== '$') {
10296 if (src[key] && src[key] !== value) {
10297 if (value.length) {
10298 value += (key === 'style' ? ';' : ' ') + src[key];
10299 } else {
10300 value = src[key];
10301 }
10302 }
10303 dst.$set(key, value, true, srcAttr[key]);
10304 }
10305 });
10306
10307 // copy the new attributes on the old attrs object
10308 forEach(src, function(value, key) {
10309 // Check if we already set this attribute in the loop above.
10310 // `dst` will never contain hasOwnProperty as DOM parser won't let it.
10311 // You will get an "InvalidCharacterError: DOM Exception 5" error if you
10312 // have an attribute like "has-own-property" or "data-has-own-property", etc.
10313 if (!dst.hasOwnProperty(key) && key.charAt(0) !== '$') {
10314 dst[key] = value;
10315
10316 if (key !== 'class' && key !== 'style') {
10317 dstAttr[key] = srcAttr[key];
10318 }
10319 }
10320 });
10321 }
10322
10323
10324 function compileTemplateUrl(directives, $compileNode, tAttrs,

Callers 2

applyDirectivesToNodeFunction · 0.70
compileTemplateUrlFunction · 0.70

Calls 1

forEachFunction · 0.70

Tested by

no test coverage detected