@@ -8,14 +8,13 @@ $( document ).ready( function() {
8
8
9
9
const $this = $ ( this ) ;
10
10
const url = $this . attr ( 'href' ) ;
11
- const params = new URL ( url ) . searchParams ;
12
11
13
12
let instance , instanceSelector ;
14
13
15
- // Get LCP instance selector .
16
- params . forEach ( ( value , key ) => {
17
- if ( 'lcp_page' === key . substring ( 0 , 8 ) ) {
18
- instance = key [ 8 ] ;
14
+ // Get LCP instance info from the class that was added in PHP .
15
+ e . delegateTarget . classList . forEach ( ( cssClass ) => {
16
+ if ( cssClass . startsWith ( 'lcpax-instance-' ) ) {
17
+ instance = cssClass . slice ( 15 ) ;
19
18
instanceSelector = `#lcp_instance_${ instance } ` ;
20
19
}
21
20
} ) ;
@@ -43,6 +42,13 @@ $( document ).ready( function() {
43
42
const $wrapper = $ ( '<div class="lcpax-nextlink-wrapper"></div>' ) ;
44
43
const $spinner = $paginator . find ( '.lcpax-spinner' ) ;
45
44
45
+ // Add the instance class to the wrapper.
46
+ this . classList . forEach ( ( cssClass ) => {
47
+ if ( cssClass . startsWith ( 'lcpax-instance-' ) ) {
48
+ $wrapper . addClass ( cssClass ) ;
49
+ }
50
+ } ) ;
51
+
46
52
// Remove the title attr, should be removed from LCP anyway.
47
53
$nextlink . removeAttr ( 'title' ) ;
48
54
@@ -57,18 +63,17 @@ $( document ).ready( function() {
57
63
58
64
const $this = $ ( this ) ;
59
65
const url = $this . attr ( 'href' ) ;
60
- const params = new URL ( url ) . searchParams ;
61
66
const $spinner = $ ( e . delegateTarget ) . find ( '.lcpax-spinner' ) ;
62
67
63
68
let instance , instanceSelector ;
64
69
65
70
// Show the spinner.
66
71
$spinner . css ( 'display' , 'inline' ) ;
67
72
68
- // Get LCP instance selector .
69
- params . forEach ( ( value , key ) => {
70
- if ( 'lcp_page' === key . substring ( 0 , 8 ) ) {
71
- instance = key [ 8 ] ;
73
+ // Get LCP instance info from the class that was added in PHP .
74
+ e . delegateTarget . classList . forEach ( ( cssClass ) => {
75
+ if ( cssClass . startsWith ( 'lcpax-instance-' ) ) {
76
+ instance = cssClass . slice ( 15 ) ;
72
77
instanceSelector = `#lcp_instance_${ instance } ` ;
73
78
}
74
79
} ) ;
0 commit comments