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

Expose getResourceId() in custom element. #5973

Merged
merged 5 commits into from
Nov 3, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address comments
  • Loading branch information
lannka committed Nov 2, 2016
commit abac7a98dcf72e16ebb46d1879a6f2f696339cb5
3 changes: 2 additions & 1 deletion src/service/resources-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,9 @@ export class Resources {
const resource = new Resource((++this.resourceIdCounter_), element, this);
if (!element.id) {
element.id = 'AMP_' + resource.getId();
element.setAttribute('amp-auto-id', element.id);
}
element.ampResourceId = resource.getId();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant more like this in custom-element.js:

BaseCustomElement {
...
  getResourceId() {
    return this.getResources().getResourceForElement(this).getId();
  }
}

Although I do kind of like the ampResourceId. If you do that - we need to also update externs I think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like your way better.


this.resources_.push(resource);
this.buildOrScheduleBuildForResource_(resource);
dev().fine(TAG_, 'element added:', resource.debugid);
Expand Down
1 change: 0 additions & 1 deletion test/functional/test-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,6 @@ describe('Resources.add', () => {
dispatchCustomEvent() {
return;
},
setAttribute() {},
};
element.build = sandbox.spy();
return element;
Expand Down