@@ -3,54 +3,26 @@ var {SetModule} = angular2now;
3
3
SetModule ( 'formlyMaterial' )
4
4
. config ( [ 'formlyConfigProvider' , ( formlyConfigProvider ) => {
5
5
6
- const addIfNotPresent = ( nodes , attr , val ) => {
7
- angular . forEach ( ( nodes , node ) => {
6
+ function addIfNotPresent ( nodes , attr , val ) {
7
+ angular . forEach ( nodes , ( node ) => {
8
8
if ( ! node . getAttribute ( attr ) ) {
9
9
node . setAttribute ( attr , val )
10
10
}
11
- } )
12
- } ;
11
+ } ) ;
12
+ }
13
13
14
- const nodeMatches = ( node , selector ) => {
14
+ function nodeMatches ( node , selector ) {
15
15
const div = document . createElement ( 'div' ) ;
16
16
17
17
div . innerHTML = node . outerHTML ;
18
18
return div . querySelector ( selector )
19
- } ;
19
+ }
20
20
21
- const getNgModelNodes = ( node , skip ) => {
22
- const selectorNot = angular . isString ( skip ) ? `:not(${ skip } )` : '' ;
23
- const skipNot = ':not([formly-skip-ng-model-attrs-manipulator])' ;
24
- const query = `[ng-model]${ selectorNot } ${ skipNot } , [data-ng-model]${ selectorNot } ${ skipNot } ` ;
21
+ function getNgModelNodes ( node ) {
22
+ const query = "[ng-model], [data-ng-model]" ;
25
23
26
- try {
27
- return node . querySelectorAll ( query )
28
- } catch ( e ) {
29
- //this code is needed for IE8, as it does not support the CSS3 ':not' selector
30
- //it should be removed when IE8 support is dropped
31
- return getNgModelNodesFallback ( node , skip )
32
- }
33
- } ;
34
-
35
- const getNgModelNodesFallback = ( node , skip ) => {
36
- const allNgModelNodes = node . querySelectorAll ( '[ng-model], [data-ng-model]' ) ;
37
- const matchingNgModelNodes = [ ] ;
38
-
39
- //make sure this array is compatible with NodeList type by adding an 'item' function
40
- matchingNgModelNodes . item = function ( i ) {
41
- return this [ i ]
42
- } ;
43
-
44
- for ( let i = 0 ; i < allNgModelNodes . length ; i ++ ) {
45
- const ngModelNode = allNgModelNodes [ i ] ;
46
-
47
- if ( ! ngModelNode . hasAttribute ( 'formly-skip-ng-model-attrs-manipulator' ) && ! ( angular . isString ( skip ) && nodeMatches ( ngModelNode , skip ) ) ) {
48
- matchingNgModelNodes . push ( ngModelNode )
49
- }
50
- }
51
-
52
- return matchingNgModelNodes
53
- } ;
24
+ return node . querySelectorAll ( query )
25
+ }
54
26
55
27
formlyConfigProvider . templateManipulators . preWrapper . push ( ( template , options ) => {
56
28
if ( angular . isDefined ( options . templateOptions . theme ) ) {
@@ -61,7 +33,7 @@ SetModule('formlyMaterial')
61
33
return template
62
34
}
63
35
node . innerHTML = template ;
64
- const modelNodes = getNgModelNodes ( node , skip ) ;
36
+ const modelNodes = getNgModelNodes ( node ) ;
65
37
66
38
if ( ! modelNodes || ! modelNodes . length ) {
67
39
return template ;
0 commit comments