amphtml
amphtml copied to clipboard
amp-social-share type attribute need more validation
Error: Failed to execute 'add' on 'DOMTokenList': The token provided ('amp-social-share-whats app') contains HTML space characters, which are not valid in tokens.
at Error (native)
at AmpSocialShare.buildCallback (http://localhost:8000/dist/v0/amp-social-share-0.1.max.js:168:28)
at amp-social-share.ElementProto.build (http://localhost:8000/dist/amp.js:4181:28)
at Resource.build (http://localhost:8000/dist/amp.js:15589:20)
at Resources.buildOrScheduleBuildForResource_ (http://localhost:8000/dist/amp.js:16461:18)
at Resources.add (http://localhost:8000/dist/amp.js:16444:10)
at amp-social-share.ElementProto.attachedCallback (http://localhost:8000/dist/amp.js:4384:21)
at registerElement (http://localhost:8000/dist/amp.js:4983:16)
at Object.upgradeOrRegisterElement (http://localhost:8000/dist/amp.js:3739:5)
at Object.registerExtendedElement (http://localhost:8000/dist/amp.js:7101:18)
When the type attribute of amp-social-share is invalid, for example, contains space, the error thrown is the above. Maybe we could make the error more clear saying that the type attribute is not valid.
/to @mkhatib
This looks like a validation error and not thrown by runtime, can you confirm @muxin ?
This is a runtime error, we could throw a better error message than this.
definitely a runtime error. this is because we use the "type" value as a class name with spaces.
element.classList.add("whats app") // throws error