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

Reflection fails when using "attribute.value" #162

Open
Aurelain opened this issue Aug 30, 2016 · 5 comments
Open

Reflection fails when using "attribute.value" #162

Aurelain opened this issue Aug 30, 2016 · 5 comments

Comments

@Aurelain
Copy link

Consider the following code:

   xtag.register('x-foo', {
        lifecycle: {
            attributeChanged: function () {
                console.log('attributeChanged');
            }
        },
        accessors: {
            bar: {
                attribute: {},
                get: function () {
                    return this.xtag.bar;
                },
                set: function (value) {
                    this.xtag.bar = value;
                    console.log('setter');
                }
            }
        }
    });
    var foo = document.createElement('x-foo');
    foo.setAttribute('bar', '1');           // attributeChanged, setter
    foo.attributes.bar.value = '2';         // attributeChanged
    console.log(foo.getAttribute('bar'));   // 2
    console.log(foo.bar);                   // 1 (should be 2!)

In my view, attributes.x.value should act exactly like setAttribute.

@csuwildcat
Copy link
Member

I will be retooling attribute code to use attributeChanged callback. This
was a historical issue back when the spec was that attribute change was a
async flow, which sucks unless you had promises or something to prevent
race code. We wanted to enforce sanity, but I should redo that code now
that the spec matches our philosophy.

On Aug 30, 2016 6:54 AM, "Aurelain" [email protected] wrote:

Consider the following code:

xtag.register('x-foo', {
lifecycle: {
attributeChanged: function () {
console.log('attributeChanged');
}
},
accessors: {
bar: {
attribute: {},
get: function () {
return this.xtag.bar;
},
set: function (value) {
this.xtag.bar = value;
console.log('setter');
}
}
}
});
var foo = document.createElement('x-foo');
foo.setAttribute('bar', '1'); // attributeChanged, setter
foo.attributes.bar.value = '2'; // attributeChanged
console.log(foo.getAttribute('bar')); // 2
console.log(foo.bar); // 1 (should be 2!)

In my view, attributes.x.value should act exactly like setAttribute.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#162, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAICynVv8dXE7q5wg7PdSQkUlK5TlJMpks5qlDYYgaJpZM4JwjVm
.

@csuwildcat
Copy link
Member

I am just running the modified code through our tests to assure 1:1 output from the previous setup. Should have this out before the end of the month.

@rafegoldberg
Copy link

whats the status on this?

@csuwildcat
Copy link
Member

I am off for 30 days starting December 13th, and will be finishing the last major update to the 1.x branch that covers this.

@rafegoldberg
Copy link

rafegoldberg commented Dec 9, 2016

@csuwildcat word, happy holidays my man. x-tag is very likely the coolest christmas/hanukkah present I'll get this year, so that pretty much makes you 🎅🏽 (seriously tho, thanks for all the work on this! it's an awesome project.)

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

3 participants