New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

This comment has been minimized.

Show comment
Hide comment
@GianlucaGuarini

GianlucaGuarini Jul 3, 2016

Member

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

Member

GianlucaGuarini commented Jul 3, 2016

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

This comment has been minimized.

Show comment
Hide comment
@imakei

imakei commented Jul 4, 2016

okey.

@menangen

This comment has been minimized.

Show comment
Hide comment
@menangen

menangen Aug 12, 2016

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.

menangen commented Aug 12, 2016

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 added a commit that referenced this issue Sep 5, 2016

GianlucaGuarini added a commit that referenced this issue Sep 5, 2016

GianlucaGuarini added a commit that referenced this issue Sep 5, 2016

GianlucaGuarini added a commit that referenced this issue Sep 10, 2016

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
@imakei

This comment has been minimized.

Show comment
Hide comment
@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