@@ -217,34 +217,37 @@ function buildAttributesMap(attrStr, jPath, tagName) {
217217 const len = matches . length ; //don't make it inline
218218 const attrs = { } ;
219219
220- // First pass: parse all attributes and update matcher with raw values
221- // This ensures the matcher has all attribute values when processors run
222- const rawAttrsForMatcher = { } ;
223- for ( let i = 0 ; i < len ; i ++ ) {
224- const attrName = this . resolveNameSpace ( matches [ i ] [ 1 ] ) ;
225- const oldVal = matches [ i ] [ 4 ] ;
226-
227- if ( attrName . length && oldVal !== undefined ) {
228- let parsedVal = oldVal ;
229- if ( this . options . trimValues ) {
230- parsedVal = parsedVal . trim ( ) ;
220+ if ( this . options . jPath === false ) {
221+ // First pass: parse all attributes and update matcher with raw values
222+ // This ensures the matcher has all attribute values when processors run
223+ const rawAttrsForMatcher = { } ;
224+ for ( let i = 0 ; i < len ; i ++ ) {
225+ const attrName = this . resolveNameSpace ( matches [ i ] [ 1 ] ) ;
226+ const oldVal = matches [ i ] [ 4 ] ;
227+
228+ if ( attrName . length && oldVal !== undefined ) {
229+ let parsedVal = oldVal ;
230+ if ( this . options . trimValues ) {
231+ parsedVal = parsedVal . trim ( ) ;
232+ }
233+ parsedVal = this . replaceEntitiesValue ( parsedVal , tagName , this . readonlyMatcher ) ;
234+ rawAttrsForMatcher [ attrName ] = parsedVal ;
231235 }
232- parsedVal = this . replaceEntitiesValue ( parsedVal , tagName , this . readonlyMatcher ) ;
233- rawAttrsForMatcher [ attrName ] = parsedVal ;
234236 }
235- }
236237
237- // Update matcher with raw attribute values BEFORE running processors
238- if ( Object . keys ( rawAttrsForMatcher ) . length > 0 && typeof jPath === 'object' && jPath . updateCurrent ) {
239- jPath . updateCurrent ( rawAttrsForMatcher ) ;
238+ // Update matcher with raw attribute values BEFORE running processors
239+ if ( Object . keys ( rawAttrsForMatcher ) . length > 0 && typeof jPath === 'object' && jPath . updateCurrent ) {
240+ jPath . updateCurrent ( rawAttrsForMatcher ) ;
241+ }
240242 }
241243
242244 // Second pass: now process attributes with matcher having full attribute context
245+ const jPathStr = this . options . jPath ? jPath . toString ( ) : this . readonlyMatcher ;
246+
243247 for ( let i = 0 ; i < len ; i ++ ) {
244248 const attrName = this . resolveNameSpace ( matches [ i ] [ 1 ] ) ;
245249
246250 // Convert jPath to string if needed for ignoreAttributesFn
247- const jPathStr = this . options . jPath ? jPath . toString ( ) : this . readonlyMatcher ;
248251 if ( this . ignoreAttributesFn ( attrName , jPathStr ) ) {
249252 continue
250253 }
@@ -659,6 +662,7 @@ function replaceEntitiesValue(val, tagName, jPath) {
659662 }
660663 }
661664 }
665+ if ( val . indexOf ( '&' ) === - 1 ) return val ;
662666 // Replace standard entities
663667 for ( const entityName of Object . keys ( this . lastEntities ) ) {
664668 const entity = this . lastEntities [ entityName ] ;
0 commit comments