@@ -33,7 +33,6 @@ const DEFAULT_EVENT_TYPE: string = EventType.CLICK;
33
33
export class ActionResolver {
34
34
private a11yClickSupport : boolean = false ;
35
35
private readonly customEventSupport : boolean ;
36
- private readonly jsnamespaceSupport : boolean ;
37
36
private readonly syntheticMouseEventSupport : boolean ;
38
37
39
38
private updateEventInfoForA11yClick ?: ( eventInfo : eventInfoLib . EventInfo ) => void = undefined ;
@@ -48,15 +47,12 @@ export class ActionResolver {
48
47
49
48
constructor ( {
50
49
customEventSupport = false ,
51
- jsnamespaceSupport = false ,
52
50
syntheticMouseEventSupport = false ,
53
51
} : {
54
52
customEventSupport ?: boolean ;
55
- jsnamespaceSupport ?: boolean ;
56
53
syntheticMouseEventSupport ?: boolean ;
57
54
} = { } ) {
58
55
this . customEventSupport = customEventSupport ;
59
- this . jsnamespaceSupport = jsnamespaceSupport ;
60
56
this . syntheticMouseEventSupport = syntheticMouseEventSupport ;
61
57
}
62
58
@@ -214,17 +210,14 @@ export class ActionResolver {
214
210
* action the given event is mapped to, if any. It parses the
215
211
* attribute value and stores it in a property on the node for
216
212
* subsequent retrieval without re-parsing and re-accessing the
217
- * attribute. In order to fully qualify jsaction names using a
218
- * namespace, the DOM is searched starting at the current node and
219
- * going through ancestor nodes until a jsnamespace attribute is
220
- * found.
213
+ * attribute.
221
214
*
222
215
* @param actionElement The DOM node to retrieve the jsaction map from.
223
216
* @param eventInfo `EventInfo` to set `action` and `actionElement` if an
224
217
* action is found on the `actionElement`.
225
218
*/
226
219
private populateActionOnElement ( actionElement : Element , eventInfo : eventInfoLib . EventInfo ) {
227
- const actionMap = this . parseActions ( actionElement , eventInfoLib . getContainer ( eventInfo ) ) ;
220
+ const actionMap = this . parseActions ( actionElement ) ;
228
221
229
222
const actionName = actionMap [ eventInfoLib . getEventType ( eventInfo ) ] ;
230
223
if ( actionName !== undefined ) {
@@ -242,11 +235,9 @@ export class ActionResolver {
242
235
* This is primarily for internal use.
243
236
*
244
237
* @param actionElement The DOM node to retrieve the jsaction map from.
245
- * @param container The node which limits the namespace lookup for a jsaction
246
- * name. The container node itself will not be searched.
247
238
* @return Map from event to qualified name of the jsaction bound to it.
248
239
*/
249
- private parseActions ( actionElement : Element , container : Node ) : { [ key : string ] : string } {
240
+ private parseActions ( actionElement : Element ) : { [ key : string ] : string } {
250
241
let actionMap : { [ key : string ] : string } | undefined = cache . get ( actionElement ) ;
251
242
if ( ! actionMap ) {
252
243
const jsactionAttribute = actionElement . getAttribute ( Attribute . JSACTION ) ;
@@ -271,58 +262,12 @@ export class ActionResolver {
271
262
}
272
263
cache . setParsed ( jsactionAttribute , actionMap ) ;
273
264
}
274
- // If namespace support is active we need to augment the (potentially
275
- // cached) jsaction mapping with the namespace.
276
- if ( this . jsnamespaceSupport ) {
277
- const noNs = actionMap ;
278
- actionMap = { } ;
279
- for ( const type in noNs ) {
280
- actionMap [ type ] = this . getFullyQualifiedAction ( noNs [ type ] , actionElement , container ) ;
281
- }
282
- }
283
265
cache . set ( actionElement , actionMap ) ;
284
266
}
285
267
}
286
268
return actionMap ;
287
269
}
288
270
289
- /**
290
- * Returns the fully qualified jsaction action. If the given jsaction
291
- * name doesn't already contain the namespace, the function iterates
292
- * over ancestor nodes until a jsnamespace attribute is found, and
293
- * uses the value of that attribute as the namespace.
294
- *
295
- * @param action The jsaction action to resolve.
296
- * @param start The node from which to start searching for a jsnamespace
297
- * attribute.
298
- * @param container The node which limits the search for a jsnamespace
299
- * attribute. This node will be searched.
300
- * @return The fully qualified name of the jsaction. If no namespace is found,
301
- * returns the unqualified name in case it exists in the global namespace.
302
- */
303
- private getFullyQualifiedAction ( action : string , start : Element , container : Node ) : string {
304
- if ( isNamespacedAction ( action ) ) {
305
- return action ;
306
- }
307
-
308
- let node : Node | null = start ;
309
- while ( node && node . nodeType === Node . ELEMENT_NODE ) {
310
- const namespace = getNamespaceFromElement ( node as Element ) ;
311
- if ( namespace ) {
312
- return namespace + Char . NAMESPACE_ACTION_SEPARATOR + action ;
313
- }
314
-
315
- // If this node is the container, stop.
316
- if ( node === container ) {
317
- break ;
318
- }
319
-
320
- node = node . parentNode ;
321
- }
322
-
323
- return action ;
324
- }
325
-
326
271
addA11yClickSupport (
327
272
updateEventInfoForA11yClick : typeof a11yClick . updateEventInfoForA11yClick ,
328
273
preventDefaultForA11yClick : typeof a11yClick . preventDefaultForA11yClick ,
@@ -334,29 +279,3 @@ export class ActionResolver {
334
279
this . populateClickOnlyAction = populateClickOnlyAction ;
335
280
}
336
281
}
337
-
338
- /**
339
- * Checks if a jsaction action contains a namespace part.
340
- */
341
- function isNamespacedAction ( action : string ) : boolean {
342
- return action . indexOf ( Char . NAMESPACE_ACTION_SEPARATOR ) >= 0 ;
343
- }
344
-
345
- /**
346
- * Returns the value of the jsnamespace attribute of the given node.
347
- * Also caches the value for subsequent lookups.
348
- * @param element The node whose jsnamespace attribute is being asked for.
349
- * @return The value of the jsnamespace attribute, or null if not found.
350
- */
351
- function getNamespaceFromElement ( element : Element ) : string | null {
352
- let namespace = cache . getNamespace ( element ) ;
353
- // Only query for the attribute if it has not been queried for
354
- // before. getAttribute() returns null if an attribute is not present. Thus,
355
- // namespace is string|null if the query took place in the past, or
356
- // undefined if the query did not take place.
357
- if ( namespace === undefined ) {
358
- namespace = element . getAttribute ( Attribute . JSNAMESPACE ) ;
359
- cache . setNamespace ( element , namespace ) ;
360
- }
361
- return namespace ;
362
- }
0 commit comments