'before-mount' won't work as expected in riot#render #1851

Closed
imakei opened this Issue Jun 27, 2016 · 4 comments

Projects

None yet

3 participants

@imakei
imakei commented Jun 27, 2016
  1. Describe your issue:

With server side rendering, variables that change in before-mount won't update in tag.
Is that a bug or a feature?

  1. Can you reproduce the issue?

my code here,

<sample>
    <p if="{ flag }"> flag is true. </p>
    <p if="{ !flag }"> flag is false. </p>
    <script>
        this.flag = false;
        console.log('flag -> ' + this.flag);
        this.on('before-mount', function(){
            this.flag = true;
            console.log('flag -> ' + this.flag);
        })
    </script>
</sample>
var riot = require("riot");
var sample = require("./sample");
console.log(riot.render('sample'));

I expected,

false
true
<sample> <p> flag is true. </p></sample>

but I got,

false
true
<sample> <p> flag is false. </p></sample>
  1. On which browser/OS does the issue appear?
    node v6.2.0
  2. Which version of Riot does it affect?
    2.4.1
  3. How would you tag this issue?
    • Question
    • Bug
    • Discussion
    • Feature request
    • Tip
    • Enhancement
    • Performance
@GianlucaGuarini
Member

Use the update method instead. This issue will be fixed in riot@next

@GianlucaGuarini GianlucaGuarini added bug and removed to verify labels Jul 3, 2016
@GianlucaGuarini GianlucaGuarini added this to the 3.0.0 milestone Jul 3, 2016
@GianlucaGuarini GianlucaGuarini self-assigned this Jul 3, 2016
@imakei
imakei commented Jul 4, 2016

okey.

@menangen

I also have issue with before-mount event with DOM working.
in my user defined tag I have simple event handler:

<tag>
<p class="caption">Do I even Exist?</p>
this.on('before-mount', function(){

      console.log(this.root);
      console.log($('.caption', this.root));

    });
<tag>

This function (Jquery selector) have no result (no "div" and no "p" collection) for using tag with nested HTML content, which located in HTML file statically, before compiling by riot.js such as:

<html lang="en">
<body>
<tag>
    <div class="caption">
    </div>
</tag>
</body>
</html>

before mounting riot tag.

@GianlucaGuarini GianlucaGuarini added a commit that referenced this issue Sep 5, 2016
@GianlucaGuarini GianlucaGuarini closes #1851 813dcd0
@GianlucaGuarini GianlucaGuarini added a commit that referenced this issue Sep 5, 2016
@GianlucaGuarini GianlucaGuarini fix #1851 54cbc62
@GianlucaGuarini GianlucaGuarini added a commit that referenced this issue Sep 5, 2016
@GianlucaGuarini GianlucaGuarini Merge branch 'next' into feature/clean-each
* next:
  fix #1851
  closes #1851
652d130
@GianlucaGuarini GianlucaGuarini added a commit that referenced this issue Sep 10, 2016
@GianlucaGuarini GianlucaGuarini Merge branch 'feature/clean-each' into next
* feature/clean-each:
  updated: riot internal functions documentation
  updated: documenting the each code, updated dev dependencies and flatten source code
  Better each handling
  fix broken virtual re-order test
  Update each fixing the unit test
  tags out of sync for virtual
  updated: re enabled the parallel nested loop tests
  updated: create aliases for document.createFragment and createTextNode
  closes #1851
  updated: removed unused vars and other micro optimizations
  updated: removed unused vars and updated watch task
  updated: avoid to pollute the tag properties with private vars
  updated: simplify the make virtual calls
  updated: enhance the mocha debugger
  removed: useless func arguments
  updated: change the each method to loop also the null items
  updated: cleaning up the each function
4138acc
@GianlucaGuarini GianlucaGuarini added a commit that closed this issue Nov 22, 2016
@GianlucaGuarini GianlucaGuarini closes #1851 1c708a2
@imakei
imakei commented Nov 23, 2016

LGTM :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment