bem / bem-xjst

bem-xjst (eXtensible JavaScript Templates): declarative template engine for the browser and server
https://bem.github.io/bem-xjst
Other
116 stars 48 forks source link

generateId is drunk #119

Closed sbmaxx closed 9 years ago

sbmaxx commented 9 years ago

http://bem.github.io/bem-xjst/

bemjson

({
    block: 'block',
    content: [1,2,3,4,5].map(function() {
        return { block: 'ololo' };
    })
});

bemhtml

block('ololo').content()(function() {
    return this.generateId()
});

All IDs are the same:

<div class="block">
    <div class="ololo">uniq144683410696013</div>
    <div class="ololo">uniq144683410696013</div>
    <div class="ololo">uniq144683410696013</div>
    <div class="ololo">uniq144683410696013</div>
    <div class="ololo">uniq144683410696013</div>
</div>

And yes, this is also critical as https://github.com/bem/bem-xjst/pull/114

qfox commented 9 years ago

This generated id is stored in ._uniq property of this class: https://github.com/bem/bem-xjst/blob/master/lib/bemhtml/runtime/index.js#L256

I'm not sure why, but there is only one instance of that. This behaviour is right from v2.0.0.

Why you can't use .identify? ;-)

sbmaxx commented 9 years ago

Why you can't use .identify? ;-)

I can, but i don't want to extend all input* islands templates ;)

qfox commented 9 years ago

Not drunk anymore. ;-) Please, close this.