Skip to content
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
Closed

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

imakei opened this issue Jun 27, 2016 · 4 comments
Assignees
Labels
Milestone

Comments

@imakei
Copy link

@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
Copy link
Member

@GianlucaGuarini 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
Copy link
Author

@imakei imakei commented Jul 4, 2016

okey.

@menangen
Copy link

@menangen 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
* 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
Copy link
Author

@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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.