Skip to content
This repository was archived by the owner on Jan 22, 2018. It is now read-only.

Commit ee10fa6

Browse files
author
Kamil Kisiela
committed
style(helpers): lint error free
1 parent 1912fbe commit ee10fa6

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

src/helpers/index.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import angular from 'angular';
22

3+
/**
4+
* Sets attribute with optional value.
5+
* Does not owerwrite.
6+
* @param {Array} nodes nodes
7+
* @param {String} attr attribute name
8+
* @param {String} val atrtibute value
9+
*/
310
function addIfNotPresent(nodes, attr, val) {
411
angular.forEach(nodes, (node) => {
512
if (!node.getAttribute(attr)) {
@@ -8,18 +15,32 @@ function addIfNotPresent(nodes, attr, val) {
815
});
916
}
1017

18+
/**
19+
* Gets all ngModels from node
20+
*/
1121
function getNgModelNodes(node) {
12-
const query = "[ng-model], [data-ng-model]";
22+
const query = '[ng-model], [data-ng-model]';
1323

14-
return node.querySelectorAll(query)
24+
return node.querySelectorAll(query);
1525
}
1626

27+
/**
28+
* Adds attribute with optional value to all elements using ngModel directive.
29+
* Handles extras.skipNgModelAttrsManipulator
30+
* And does not overwrite attriutes
31+
*
32+
* @param {String} template Template provided by formly template manipulator
33+
* @param {Object} options Options provided by formly template manipulator
34+
* @param {String} attrName Attribute's name
35+
* @param {String|undefined} Attribute's value (optional)
36+
* @return {String} result
37+
*/
1738
export function ngModelAttrsManipulator(template, options, attrName, attrValue) {
1839
const node = document.createElement('div');
1940
const skip = options.extras && options.extras.skipNgModelAttrsManipulator;
2041

2142
if (skip === true) {
22-
return template
43+
return template;
2344
}
2445
node.innerHTML = template;
2546
const modelNodes = getNgModelNodes(node);

0 commit comments

Comments
 (0)