Code Monkey home page Code Monkey logo

Comments (5)

maccman avatar maccman commented on June 3, 2024

Give you give me some example code, I can't replicate it?

from spine.

jeef3 avatar jeef3 commented on June 3, 2024

This is either an issue or by design? (Firefox)

var e1 = this.records[id];
var e2 = this.records[id].clone();

If I modify e1, the change is reflected in e2. If I modify e2, the change is not reflected in e1. In other words, modifying the original "updates" the clones. But modifying the clone does not appear to update the original.

from spine.

maccman avatar maccman commented on June 3, 2024

You shouldn't be accessing this.records[] directly - it's the raw records. Every function that returns records, such as find(), makes sure only proxies are returned. Yes, this behavior is expected.

The one place this catches people out, is in the following scenario:

var asset = Asset.create({name: "test", id: "foo"});
Asset.find("foo").updateAttributes({name: "test2"});
assertEqual(asset.name, "test2"); // fails

This is because asset isn't a clone - so doesn't reflect updates. Unfortunately there isn't a cross browser way of setting the asset's prototype upon creation, turning it into a clone. There isn't a way around this apart from calling asset.reload(). Hope that answers your question.

from spine.

lancejpollard avatar lancejpollard commented on June 3, 2024

So maybe this is a bug with Safari, not too sure. Took me a while to pinpoint what might be happening.

What's happening is that Object.create doesn't work in the web inspector (at least in Safari 5.0.5 on Mac 10.6). Object.create works for simple objects, such as Object.create({}), but not on the Spine.js models.

But when the javascript runs in the browser (i.e. App.Models.Post.first() is run when the script file loads, instead of me manually typing App.Models.Post.first() into the web inspector), it works fine. So the code works, I just can't mess with it in the web inspector.

Changing the .clone method in Spine.js from return Object.create(this); to return this.dup(); solves this specific issue, but it probably will cause other problems. Writing javascript tests is cutting out the need to use the web inspector, so that's a better approach.

Thanks,
Lance

from spine.

maccman avatar maccman commented on June 3, 2024

Yes, complex objects not appearing in the console is a webkit issue, fixed
in the nightlies I believe. In the mean time you can solve it by doing
JSON.stringify(ob).

On Mon, Jul 18, 2011 at 4:16 PM, viatropos <
[email protected]>wrote:

So maybe this is a bug with Safari, not too sure. Took me a while to
pinpoint what might be happening.

What's happening is that Object.create doesn't work in the web inspector
(at least in Safari 5.0.5 on Mac 10.6). Object.create works for simple
objects, such as Object.create({}), but not on the Spine.js models.

But when the javascript runs in the browser (i.e. App.Models.Post.first()
is run when the script file loads, instead of me manually typing
App.Models.Post.first() into the web inspector), it works fine. So the
code works, I just can't mess with it in the web inspector.

Changing the .clone method in Spine.js from return Object.create(this);
to return this.dup(); solves this specific issue, but it probably will
cause other problems. Writing javascript tests is cutting out the need to
use the web inspector, so that's a better approach.

Thanks,
Lance

Reply to this email directly or view it on GitHub:
https://github.com/maccman/spine/issues/61#issuecomment-1602986

Alex MacCaw

+12147175129
@maccman

http://alexmaccaw.co.uk | http://www.leadthinking.com | http://socialmod.com

from spine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.