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
amp-bind: Add function to print bind's scope #8876
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor suggestion.
extensions/amp-bind/0.1/bind-impl.js
Outdated
const index = seen.indexOf(value); | ||
if (index !== -1) { | ||
const name = seenNames[index]; | ||
return `**Circular reference to '${name}'**`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use node's handling of circular references:
> var a = {};
undefined
> a.a = a;
{ a: [Circular] }
You can remove seenNames
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add this to the public docs.
extensions/amp-bind/0.1/bind-impl.js
Outdated
@@ -154,6 +154,7 @@ export class Bind { | |||
// Expose for testing on dev. | |||
if (getMode().localDev) { | |||
AMP.reinitializeBind = this.initialize_.bind(this); | |||
AMP.printAmpState = this.printAmpState_.bind(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: AMP.printState
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
079d29f
to
0af5188
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added amp-bind.md
to the PR.
extensions/amp-bind/0.1/bind-impl.js
Outdated
@@ -154,6 +154,7 @@ export class Bind { | |||
// Expose for testing on dev. | |||
if (getMode().localDev) { | |||
AMP.reinitializeBind = this.initialize_.bind(this); | |||
AMP.printAmpState = this.printAmpState_.bind(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
325494b
to
5a1ca5e
Compare
Sorry for chipping in here, but is this really in prod? I'm in development mode (#development=1 in the fragment) and using
But in console, I get this:
The AMP namespace is there, but it doesn't have a |
Great, thanks! I didn't realize it was only enabled for localhost... |
I get "undefined" when I do AMP.printState() on console although the page is on localhost. |
@stoneshower Looks like you still need |
@choumx with |
where is #log=4 documented? I also can't find any reference to AMP.printState on any of your documentation either. https://ampbyexample.com/components/amp-bind/ you would think if you want your technology to be adopted with the looming "google will index you higher than your competitor" axe hanging above one's head, that basic debugging tools would help. |
@AcidRaZor Thanks for the feedback. We're also working on more powerful debugging tools, e.g. #16830. I'd love to eventually have a Chrome extension similar to React Developer Tools, but unfortunately haven't had the time to implement this yet. Any interest in contributing to AMP? 😋 |
Adds a function enabled in dev mode to print out bind's scope.
The function allows for scope to have circular references, though currently I'm not sure that it's possible for such references to get into bind's scope.
Fixes #8719
/to @choumx