Git Product home page Git Product logo

Comments (5)

astro avatar astro commented on July 22, 2024

Both clone() and the getters were contributions. Help me with a pull request or give me some time. :-)

from ltx.

bobwolff68 avatar bobwolff68 commented on July 22, 2024

I actually tried fixing it myself, but I must be missing a key element in Javascript. I'm a long-time C++ guy and quite new to Javascript so I know there's a LOT I don't know. :-)

I tried basically at the top-level of the element doing something like:
for (k in el.attrs)
el[k] = el.attrs.k;

this did produce the getters, but it basically made a 'duplicate' of the .attrs rather than a link to them. Subsequent accesses of:
el.type = 'set';

This would change el.type, but it would not change el.attrs.type and so it becomes broken. I realize this is a Javascript misunderstanding, and so if you're looking for a pull request from me, I'll need you to give me a hint as to what to study in order to make that property-link appropriately so that I can fix it the right way. :)

from ltx.

astro avatar astro commented on July 22, 2024

Could you please write a few tests for this problem?

from ltx.

bobwolff68 avatar bobwolff68 commented on July 22, 2024

Hey there. Ok - so I think I'm losing my mind...here's my test. But unfortunately the failure is not what I anticipated. I know for a certainty that I had a LOT of code (and I can look through my own repo to prove this) which accessed directly:
stanza.to
rather than
stanza.attrs.to
and it worked in my code...maybe because I was receiving the stanza rather than simply generating one directly using new ltx.Element() ? So, the following snippet was supposed to demonstrate that .to works in the original version but after cloning, the .to should fail with undefined. But both are undefined. Sigh.

var ltx = require('ltx')

var orig = new ltx.Element('message', {to: '[email protected]', type: 'chat'})
.c('x', {xmlns: 'http://jabber.org/protocol/muc'});

console.log("orig: attrs.to: " + orig.root().attrs.to + " - orig: .to: " + orig.root().to);

var cln = orig.root().clone();

console.log("cln: attrs.to: " + cln.root().attrs.to + " - cln: .to: " + cln.root().to);

from ltx.

lloydwatkin avatar lloydwatkin commented on July 22, 2024

Closing due to inactivity. If this still needs discussion please reopen. Cheers, Lloyd.

from ltx.

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.