* @param {!./ampdoc-impl.AmpDoc} ampdoc * @param {(!Document|!ShadowRoot)=} opt_root
(ampdoc, opt_root)
| 235 | * @param {(!Document|!ShadowRoot)=} opt_root |
| 236 | */ |
| 237 | constructor(ampdoc, opt_root) { |
| 238 | /** @const {!./ampdoc-impl.AmpDoc} */ |
| 239 | this.ampdoc = ampdoc; |
| 240 | |
| 241 | /** @const {!Document|!ShadowRoot} */ |
| 242 | this.root_ = opt_root || ampdoc.getRootNode(); |
| 243 | |
| 244 | /** @const {boolean} */ |
| 245 | this.isEmail_ = |
| 246 | this.ampdoc.isSingleDoc() && |
| 247 | isAmp4Email(/** @type {!Document} */ (this.root_)); |
| 248 | |
| 249 | /** |
| 250 | * Optional allowlist of actions, e.g.: |
| 251 | * |
| 252 | * [{tagOrTarget: 'AMP', method: 'navigateTo'}, |
| 253 | * {tagOrTarget: 'AMP-FORM', method: 'submit'}, |
| 254 | * {tagOrTarget: '*', method: 'show'}] |
| 255 | * |
| 256 | * If not null, any actions that are not in the allowlist will be ignored |
| 257 | * and throw a user error at invocation time. Note that `tagOrTarget` is |
| 258 | * always the canonical uppercased form (same as |
| 259 | * `Element.prototype.tagName`). If `tagOrTarget` is the wildcard '*', then |
| 260 | * the allowlisted method is allowed on any tag or target. |
| 261 | * |
| 262 | * For AMP4Email format documents, allowed actions are autogenerated. |
| 263 | * @private {?Array<{tagOrTarget: string, method: string}>} |
| 264 | */ |
| 265 | this.allowlist_ = this.isEmail_ ? DEFAULT_EMAIL_ALLOWLIST : null; |
| 266 | |
| 267 | /** @const @private {!{[key: string]: ActionHandlerDef}} */ |
| 268 | this.globalTargets_ = map(); |
| 269 | |
| 270 | /** |
| 271 | * @const @private {!{[key: string]: {handler: ActionHandlerDef, minTrust: ActionTrust_Enum}}} |
| 272 | */ |
| 273 | this.globalMethodHandlers_ = map(); |
| 274 | |
| 275 | // Add core events. |
| 276 | this.addEvent('tap'); |
| 277 | this.addEvent('submit'); |
| 278 | this.addEvent('change'); |
| 279 | this.addEvent('input-debounced'); |
| 280 | this.addEvent('input-throttled'); |
| 281 | this.addEvent('valid'); |
| 282 | this.addEvent('invalid'); |
| 283 | } |
| 284 | |
| 285 | /** |
| 286 | * @param {string} name |
nothing calls this directly
no test coverage detected