mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
For each property should work with Map instances.
This commit is contained in:
parent
b0d77b8cb0
commit
405ff119b4
@ -171,6 +171,10 @@ exports.fp = function forEachPropertyHelper(o, func) {
|
||||
for (var i=0; i<o.length; i++) {
|
||||
func(i, o[i]);
|
||||
}
|
||||
} else if (typeof Map && o instanceof Map) {
|
||||
o.forEach(function(v, k) {
|
||||
func(k, v);
|
||||
});
|
||||
} else {
|
||||
for (var k in o) {
|
||||
if (o.hasOwnProperty(k)) {
|
||||
|
||||
1
test/autotests/render/for-props-map/expected.html
Normal file
1
test/autotests/render/for-props-map/expected.html
Normal file
@ -0,0 +1 @@
|
||||
[foo=low][bar=high]
|
||||
3
test/autotests/render/for-props-map/template.marko
Normal file
3
test/autotests/render/for-props-map/template.marko
Normal file
@ -0,0 +1,3 @@
|
||||
<for(name,value in data.myMap)>
|
||||
[${name}=${value}]
|
||||
</for>
|
||||
10
test/autotests/render/for-props-map/test.js
Normal file
10
test/autotests/render/for-props-map/test.js
Normal file
@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
const myMap = new Map();
|
||||
|
||||
myMap.set('foo', 'low');
|
||||
myMap.set('bar', 'high');
|
||||
|
||||
exports.templateData = {
|
||||
myMap: myMap
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user