{"ScriptPreparationCode":null,"TestCases":[{"Name":"PR #631","Code":"const xAttrRE = /^x-(on|bind|data|text|html|model|if|for|show|cloak|transition|ref|spread)\\b/\r\n\r\nfunction isXAttr(attr) {\r\n const name = replaceAtAndColonWithStandardSyntax(attr.name)\r\n\r\n return xAttrRE.test(name)\r\n}\r\n\r\nfunction replaceAtAndColonWithStandardSyntax(name) {\r\n if (name.startsWith(\u0027@\u0027)) {\r\n return name.replace(\u0027@\u0027, \u0027x-on:\u0027)\r\n } else if (name.startsWith(\u0027:\u0027)) {\r\n return name.replace(\u0027:\u0027, \u0027x-bind:\u0027)\r\n }\r\n\r\n return name\r\n}\r\n\r\nfunction parseHtmlAttribute({ name, value }) {\r\n const normalizedName = replaceAtAndColonWithStandardSyntax(name)\r\n\r\n const typeMatch = normalizedName.match(xAttrRE)\r\n const valueMatch = normalizedName.match(/:([a-zA-Z\\-:]\u002B)/)\r\n const modifiers = normalizedName.match(/\\.[^.\\]]\u002B(?=[^\\]]*$)/g) || []\r\n\r\n return {\r\n type: typeMatch ? typeMatch[1] : null,\r\n value: valueMatch ? valueMatch[1] : null,\r\n modifiers: modifiers.map(i =\u003E i.replace(\u0027.\u0027, \u0027\u0027)),\r\n expression: value,\r\n }\r\n}\r\n\r\nfunction getXAttrs(el, component, type) {\r\n let directives = Array.from(el.attributes).filter(isXAttr).map(parseHtmlAttribute)\r\n\r\n // Get an object of directives from x-spread.\r\n let spreadDirective = directives.filter(directive =\u003E directive.type === \u0027spread\u0027)[0]\r\n\r\n if (spreadDirective) {\r\n let spreadObject = saferEval(spreadDirective.expression, component.$data)\r\n\r\n // Add x-spread directives to the pile of existing directives.\r\n directives = directives.concat(Object.entries(spreadObject).map(([name, value]) =\u003E parseHtmlAttribute({ name, value })))\r\n }\r\n \r\n if (type) return directives.filter(i =\u003E i.type === type)\r\n\r\n return directives;\r\n}\r\n\r\ngetXAttrs(document.getElementById(\u0027test\u0027))","IsDeferred":false},{"Name":"v2.4.0","Code":"const xAttrRE = /^x-(on|bind|data|text|html|model|if|for|show|cloak|transition|ref|spread)\\b/\r\n\r\nfunction isXAttr(attr) {\r\n const name = replaceAtAndColonWithStandardSyntax(attr.name)\r\n\r\n return xAttrRE.test(name)\r\n}\r\n\r\nfunction replaceAtAndColonWithStandardSyntax(name) {\r\n if (name.startsWith(\u0027@\u0027)) {\r\n return name.replace(\u0027@\u0027, \u0027x-on:\u0027)\r\n } else if (name.startsWith(\u0027:\u0027)) {\r\n return name.replace(\u0027:\u0027, \u0027x-bind:\u0027)\r\n }\r\n\r\n return name\r\n}\r\n\r\nfunction parseHtmlAttribute({ name, value }) {\r\n const normalizedName = replaceAtAndColonWithStandardSyntax(name)\r\n\r\n const typeMatch = normalizedName.match(xAttrRE)\r\n const valueMatch = normalizedName.match(/:([a-zA-Z\\-:]\u002B)/)\r\n const modifiers = normalizedName.match(/\\.[^.\\]]\u002B(?=[^\\]]*$)/g) || []\r\n\r\n return {\r\n type: typeMatch ? typeMatch[1] : null,\r\n value: valueMatch ? valueMatch[1] : null,\r\n modifiers: modifiers.map(i =\u003E i.replace(\u0027.\u0027, \u0027\u0027)),\r\n expression: value,\r\n }\r\n}\r\n\r\nfunction getXAttrs(el, component, type) {\r\n let directives = Array.from(el.attributes).filter(isXAttr).map(parseHtmlAttribute)\r\n\r\n // Get an object of directives from x-spread.\r\n let spreadDirective = directives.filter(directive =\u003E directive.type === \u0027spread\u0027)[0]\r\n\r\n if (spreadDirective) {\r\n let spreadObject = saferEval(spreadDirective.expression, component.$data)\r\n\r\n // Add x-spread directives to the pile of existing directives.\r\n directives = directives.concat(Object.entries(spreadObject).map(([name, value]) =\u003E parseHtmlAttribute({ name, value })))\r\n }\r\n\r\n return directives.filter(i =\u003E {\r\n // If no type is passed in for filtering, bypass filter\r\n if (! type) return true\r\n\r\n return i.type === type\r\n })\r\n}\r\n\r\ngetXAttrs(document.getElementById(\u0027test\u0027))","IsDeferred":false}]}