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

amp-bind: Restore canBind() #8272

Merged
merged 5 commits into from Mar 21, 2017

Conversation

dreamofabear
Copy link

@dreamofabear dreamofabear commented Mar 20, 2017

Fixes #8271.

@dreamofabear
Copy link
Author

/to @jridgewell @kmh287 /cc @molnarg

Copy link
Contributor

@kmh287 kmh287 left a comment

Choose a reason for hiding this comment

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

Looks good. Just one comment.

@@ -33,9 +34,23 @@ let PropertyRulesDef;
* @private {Object<string, ?PropertyRulesDef>}
*/
const GLOBAL_PROPERTY_RULES = map({
'text': null,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to allow any tag to have the [text] attribute? I could see this being potentially problematic on a <div> for instance, where reassigning its textContent could be used to remove its contents.

Copy link
Author

Choose a reason for hiding this comment

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

Yea, I originally had only whitelisted text elements for [text] but I think a more general solution is more consistent (Node.textContent is not limited to text elements) and makes the validator changes smaller.

@kmh287
Copy link
Contributor

kmh287 commented Mar 21, 2017

Also, depending on which PR you submit first, don't forget to add amp-iframe to the rules map 😄

// If there are no rules governing this binding, return true.
if (!rules) {
// If binding to (tag, property) is not allowed, return false.
if (rules === undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be calling #canBind.

Copy link
Author

Choose a reason for hiding this comment

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

It did at one point, but it causes a duplicate call to rulesForTagAndProperty_. This is slightly more efficient.

Copy link
Author

@dreamofabear dreamofabear left a comment

Choose a reason for hiding this comment

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

Thanks for the reviews.

@@ -33,9 +34,23 @@ let PropertyRulesDef;
* @private {Object<string, ?PropertyRulesDef>}
*/
const GLOBAL_PROPERTY_RULES = map({
'text': null,
Copy link
Author

Choose a reason for hiding this comment

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

Yea, I originally had only whitelisted text elements for [text] but I think a more general solution is more consistent (Node.textContent is not limited to text elements) and makes the validator changes smaller.

// If there are no rules governing this binding, return true.
if (!rules) {
// If binding to (tag, property) is not allowed, return false.
if (rules === undefined) {
Copy link
Author

Choose a reason for hiding this comment

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

It did at one point, but it causes a duplicate call to rulesForTagAndProperty_. This is slightly more efficient.

@dreamofabear dreamofabear merged commit a508084 into ampproject:master Mar 21, 2017
@dreamofabear dreamofabear deleted the bind-revert-can-bind branch March 21, 2017 21:31
mrjoro pushed a commit to mrjoro/amphtml that referenced this pull request Apr 28, 2017
* restore canBind()

* disallow binding to 'name'

* add brightcove and youtube

* update tests

* fix amp property rules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants