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

Commit 6c7be7a

Browse files
author
Kamil Kisiela
committed
fix(templateOptions.theme): missing md-theme attribute
1 parent ae2f17b commit 6c7be7a

File tree

2 files changed

+16
-39
lines changed

2 files changed

+16
-39
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [Unreleased]
6+
### Fixed
7+
- missing md-theme attribute when using templateOptions.theme
8+
59
## [0.5.1] - 2015-11-18
610
### Changed
711
- Refactor all files to use Strict Dependency Injection
@@ -60,6 +64,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
6064

6165
## 0.0.1 - 2015-11-06
6266

67+
[Unreleased]: https://github.com/wieldo/angular-formly-templates-material/compare/v0.5.1...HEAD
6368
[0.5.1]: https://github.com/wieldo/angular-formly-templates-material/compare/v0.5.0...v0.5.1
6469
[0.5.0]: https://github.com/wieldo/angular-formly-templates-material/compare/v0.4.0...v0.5.0
6570
[0.4.0]: https://github.com/wieldo/angular-formly-templates-material/compare/v0.3.0...v0.4.0

lib/client/run/md-theme-manipulator.js

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,26 @@ var {SetModule} = angular2now;
33
SetModule('formlyMaterial')
44
.config(['formlyConfigProvider', (formlyConfigProvider) => {
55

6-
const addIfNotPresent = (nodes, attr, val) => {
7-
angular.forEach((nodes, node) => {
6+
function addIfNotPresent(nodes, attr, val) {
7+
angular.forEach(nodes, (node) => {
88
if (!node.getAttribute(attr)) {
99
node.setAttribute(attr, val)
1010
}
11-
})
12-
};
11+
});
12+
}
1313

14-
const nodeMatches = (node, selector) => {
14+
function nodeMatches(node, selector) {
1515
const div = document.createElement('div');
1616

1717
div.innerHTML = node.outerHTML;
1818
return div.querySelector(selector)
19-
};
19+
}
2020

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]";
2523

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+
}
5426

5527
formlyConfigProvider.templateManipulators.preWrapper.push((template, options) => {
5628
if (angular.isDefined(options.templateOptions.theme)) {
@@ -61,7 +33,7 @@ SetModule('formlyMaterial')
6133
return template
6234
}
6335
node.innerHTML = template;
64-
const modelNodes = getNgModelNodes(node, skip);
36+
const modelNodes = getNgModelNodes(node);
6537

6638
if (!modelNodes || !modelNodes.length) {
6739
return template;

0 commit comments

Comments
 (0)