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

y.val('something').getDom() !== yxml.getDom() causing fail in syncing #3

Closed
cphyc opened this issue Mar 5, 2015 · 3 comments
Closed

Comments

@cphyc
Copy link

cphyc commented Mar 5, 2015

I have the following HTML code

  <body>
    <p id="container">This is default.</p>
  </body>

If I create an object this way :

    var connector = new Y.WebRTC("test", {url: config.server});

    var y = new Y(connector);
    var p = document.getElementById("container");
    var yxml = new Y.Xml(p);

    y.val("test", yxml);

and then go to the console and do in one of two browser : y.val("test").getDom().textContent = "Changed in local.", then the value gets updated in one of the two browser.
In the other browser, if I type y.val('test').getDom().textContent, I get "Changed in local" but yxml.getDom().textContent gives me "This is default" as well as p.textContent.

@cphyc
Copy link
Author

cphyc commented Mar 5, 2015

Here's the whole code.

<!DOCTYPE html>
<html>
  <head lang="en">
    <meta charset="UTF-8">
    <title>Yjs test</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <script src="bower_components/webcomponentsjs/webcomponents.js"></script>
    <script src="bower_components/yjs/y.js"></script>
    <script src="bower_components/yjs/y-object.js"></script>
    <script src="bower_components/y-list/y-list.js"></script>
    <script src="bower_components/y-xml/y-xml.js"></script>
    <script src="bower_components/y-webrtc/y-webrtc.js"></script>
    <script src="config.js"></script>
  </head>
  <body>
    <p id="container">This is default.</p>
  </body>
  <script>
   var connector = new Y.WebRTC("test", {url: config.server});

   var y = new Y(connector);
   var p = document.getElementById("container");
   var yxml = new Y.Xml(p);

   y.val("test", yxml);

  </script>
</html>

@dmonad
Copy link
Contributor

dmonad commented Mar 5, 2015

This is not a bug.

This is what happens: User 1 puts p on y("test"). User 2 joins the session and also puts its own version of p on y("test"). Therefore, the p element of user 1 is not shared anymore (because it was replaced by user 2. In the examples directory I show how you can ensure that there is only one version of p exists in the body.

Because this is a common usage of the xml type, I'll find a way to make this easier. I'll also include this in the documentation.

@cphyc
Copy link
Author

cphyc commented Mar 9, 2015

Ok, thanks for the hint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants