diff --git a/package.json b/package.json index a0574fd8..3f53b1f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unexpected-dom", - "version": "4.9.4", + "version": "4.9.5", "description": "DOM plugin for the unexpected assertion libary", "main": "lib/index.js", "files": [ diff --git a/unexpected-dom.js b/unexpected-dom.js index bb662cb0..3ecf3f36 100644 --- a/unexpected-dom.js +++ b/unexpected-dom.js @@ -83,7 +83,7 @@ function isEnumeratedAttribute(attrName) { function validateStyles(expect, str) { var invalidStyles = str.split(';').filter(function (part) { - return !/^\s*\w+\s*:\s*\w+\s*$|^$/.test(part); + return !/^\s*(\w|-)+\s*:\s*(\w|-)+\s*$|^$/.test(part); }); if (invalidStyles.length > 0) { @@ -2168,4 +2168,4 @@ Prism.languages.js = Prism.languages.javascript; },{}]},{},[1])(1) }); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJsaWIvaW5kZXguanMiLCJsaWIvbWF0Y2hlc1NlbGVjdG9yLmpzIiwibm9kZV9tb2R1bGVzL21hZ2ljcGVuLXByaXNtL2xpYi9tYWdpY1BlblByaXNtLmpzIiwibm9kZV9tb2R1bGVzL21hZ2ljcGVuLXByaXNtL3BhY2thZ2UuanNvbiIsIm5vZGVfbW9kdWxlcy9wcmlzbWpzL2NvbXBvbmVudHMvcHJpc20tY3NwLmpzIiwibm9kZV9tb2R1bGVzL3ByaXNtanMvY29tcG9uZW50cy9wcmlzbS1ncmFwaHFsLmpzIiwibm9kZV9tb2R1bGVzL3ByaXNtanMvcHJpc20uanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7QUNBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNB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cnRlZE9wdGlvbnMuam9pbignLCAnKSk7XG4gICAgICB9XG5cbiAgICAgIHZhciBwcm9taXNlQnlLZXkgPSB7XG4gICAgICAgIG5hbWU6IGV4cGVjdC5wcm9taXNlKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICBpZiAodmFsdWUgJiYgdHlwZW9mIHZhbHVlLm5hbWUgIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICByZXR1cm4gYnViYmxlRXJyb3IoZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICByZXR1cm4gZXhwZWN0KGlzSHRtbCA/IHN1YmplY3Qubm9kZU5hbWUudG9Mb3dlckNhc2UoKSA6IHN1YmplY3Qubm9kZU5hbWUsICd0byBzYXRpc2Z5JywgdmFsdWUubmFtZSk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICB9XG4gICAgICAgIH0pLFxuICAgICAgICBjaGlsZHJlbjogZXhwZWN0LnByb21pc2UoZnVuY3Rpb24gKCkge1xuICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUuY2hpbGRyZW4gIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlLnRleHRDb250ZW50ICE9PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ1RoZSBjaGlsZHJlbiBhbmQgdGV4dENvbnRlbnQgcHJvcGVydGllcyBhcmUgbm90IHN1cHBvcnRlZCB0b2dldGhlcicpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGJ1YmJsZUVycm9yKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgcmV0dXJuIGV4cGVjdChtYWtlQXR0YWNoZWRET01Ob2RlTGlzdChzdWJqZWN0LmNoaWxkTm9kZXMsIHN1YmplY3Qub3duZXJEb2N1bWVudC5jb250ZW50VHlwZSksICd0byBzYXRpc2Z5JywgdmFsdWUuY2hpbGRyZW4pO1xuICA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ICAgICAgICAgICAgICByZXR1cm4gZXhwZWN0KGFjdHVhbENsYXNzZXMuc29ydCgpLCAndG8gZXF1YWwnLCBleHBlY3RlZENsYXNzZXMuc29ydCgpKTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiAoZXhwZWN0ZWRDbGFzc2VzLmxlbmd0aCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgcmV0dXJuIGJ1YmJsZUVycm9yKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGV4cGVjdChleHBlY3RlZENsYXNzZXMsICd0byBiZSBlbXB0eScpO1xuICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBidWJibGVFcnJvcihmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICByZXR1cm4gZXhwZWN0LmFwcGx5KHVuZGVmaW5lZCwgW2FjdHVhbENsYXNzZXMsICd0byBjb250YWluJ10uY29uY2F0KF90b0NvbnN1bWFibGVBcnJheShleHBlY3RlZENsYXNzZXMpKSk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSBpZiAoYXR0cmlidXRlTmFtZSA9PT0gJ3N0eWxlJykge1xuICAgICAgICAgICAgICB2YXIgZXhwZWN0ZWRTdHlsZU9iaiA9IHZvaWQgMDtcbiAgICAgICAgICAgICAgaWYgKHR5cGVvZiBleHBlY3RlZFZhbHVlQnlBdHRyaWJ1dGVOYW1lLnN0eWxlID09PSAnc3RyaW5nJykge1xuICAgICAgICAgICAgICAgIHZhbGlkYXRlU3R5bGVzKGV4cGVjdCwgZXhwZWN0ZWRWYWx1ZUJ5QXR0cmlidXRlTmFtZS5zdHlsZSk7XG4gICAgICAgICAgICAgICAgZXhwZWN0ZWRTdHlsZU9iaiA9IHN0eWxlU3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CwgX2RpZmY3LCBpbnNwZWN0LCBlcXVhbCkge1xuICAgICAgICAgICAgICBvdXRwdXQuYmxvY2soZnVuY3Rpb24gKG91dHB1dCkge1xuICAgICAgICAgICAgICAgIHZhciBzZWVuRXJyb3IgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICBvdXRwdXQucHJpc21QdW5jdHVhdGlvbignPCcpLnByaXNtVGFnKGlzSHRtbCA/IHN1YmplY3Qubm9kZU5hbWUudG9Mb3dlckNhc2UoKSA6IHN1YmplY3Qubm9kZU5hbWUpO1xuICAgICAgICAgICAgICAgIGlmIChwcm9taXNlQnlLZXkubmFtZS5pc1JlamVjdGVkKCkpIHtcbiAgICAgICAgICAgICAgICAgIHNlZW5FcnJvciA9IHRydWU7XG4gICAgICAgICAgICAgICAgICB2YXIgbmFtZUVycm9yID0gcHJvbWlzZUJ5S2V5Lm5hbWUucmVhc29uKCk7XG4gICAgICAgICAgICAgICAgICBvdXRwdXQuc3AoKS5hbm5vdGF0aW9uQmxvY2soZnVuY3Rpb24gKG91dHB1dCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gb3V0cHV0LmVycm9yKG5hbWVFcnJvciAmJiBuYW1lRXJyb3IuZ2V0TGFiZWwoKSB8fCAnc2hvdWxkIHNhdGlzZnknKS5zcCgpLmFwcGVuZChpbnNwZWN0KHZhbHVlLm5hbWUpKTtcbiAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB2YXIgaW5zcGVjdGVkQXR0cmlidXRlcyA9IFtdO1xuICAgICAgICAgICAgICAgIE9iamVjdC5rZXlzKGF0dHJzKS5mb3JFYWNoKGZ1bmN0aW9uIChhdHRyaWJ1dGVOYW1lKSB7XG4gICAgICAgICAgICAgICAgICB2YXIgYXR0cmlidXRlT3V0cHV0ID0gb3V0cHV0LmNsb25lKCk7XG4gICAgICAgICAgICAgICAgICB2YXIgcHJvbWlzZSA9IHByb21pc2VCeUtleS5hdHRyaWJ1dGVzW2F0dHJpYnV0ZU5hbWVdO1xuICAgICAgICAgICAgICAgICAgd3JpdGVBdHRyaWJ1dGVUb01hZ2ljUGVuKGF0dHJpYnV0ZU91dHB1dCwgYXR0cmlidXRlTmFtZSwgYXR0cnNbYXR0cmlidXRlTmFtZV0sIGlzSHRtbCk7XG4gICAgICAgICAgICAgICAgICBpZiAocHJvbWlzZSAmJiBwcm9taXNlLmlzRnVsZmlsbGVkKCkgfHwgIXByb21pc2UgJiYgKCFvbmx5QXR0cmlidXRlcyB8fCBleHBlY3RlZEF0dHJpYnV0ZU5hbWVzLmluZGV4T2YoYXR0cmlidXRlTmFtZSkgIT09IC0xKSkge30gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHNlZW5FcnJvciA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIGF0dHJpYnV0ZU91dHB1dC5zcCgpLmFubm90YXRpb25CbG9jayhmdW5jdGlvbiAob3V0cHV0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgaWYgKHByb21pc2UgJiYgdHlwZW9mIGV4cGVjdGVkVmFsdWVCeUF0dHJpYnV0ZU5hbWVbYXR0cmlidXRlTmFtZV0gIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXQuYXBwZW5kRXJyb3JNZXNzYWdlKHByb21pc2UucmVhc29uKCkpO1xuICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBvbmx5QXR0cmlidXRlcyA9PT0gdHJ1ZVxuICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0LmVycm9yKCdzaG91bGQgYmUgcmVtb3ZlZCcpO1xuICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICBpbnNwZWN0ZWRBdHRyaWJ1dGVzLnB1c2goYXR0cmlidXRlT3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gICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgaW5zcGVjdGVkQXR0cmlidXRlcy5wdXNoKGF0dHJpYnV0ZU91dHB1dCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICBpZiAoaW5zcGVjdGVkQXR0cmlidXRlcy5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgICBpZiAoc2VlbkVycm9yKSB7XG4gICAgICAgICAgICAgICAgICAgIG91dHB1dC5ubCgpLmluZGVudExpbmVzKCkuaW5kZW50KCkuYmxvY2soZnVuY3Rpb24gKG91dHB1dCkge1xuICAgICAgICAgICAgICAgICAgICAgIGluc3BlY3RlZEF0dHJpYnV0ZXMuZm9yRWFjaChmdW5jdGlvbiAoaXRlbSwgaSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dC5ubCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0LmFwcGVuZChpdGVtKTtcbiAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgfSkub3V0ZGVudExpbmVzKCkubmwoKTtcbiAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIG91dHB1dC5zcCgpO1xuICAgICAgICAgICAgICAgICAgICBpbnNwZWN0ZWRBdHRyaWJ1dGVzLmZvckVhY2goZnVuY3Rpb24gKGl0ZW0sIGkpIHtcbiAgICAgICAgICAgICAgICAgICAgICBpZiAoaSA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dC5zcCgpO1xuICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICBvdXRwdXQuYXBwZW5kKGl0ZW0pO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNlZW5FcnJvcikge1xuICAgICAgICAgICAgICAgICAgLy8gVGhlIHRhZyBuYW1lIG1pc21hdGNoZWRcbiAgICAgICAgICAgICAgICAgIG91dHB1dC5ubCgpO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIG91dHB1dC5wcmlzbVB1bmN0dWF0aW9uKCc+Jyk7XG4gICAgICAgICAgICAgICAgdmFyIGNoaWxkcmVuRXJyb3IgPSBwcm9taXNlQnlLZXkuY2hpbGRyZW4uaXNSZWplY3RlZCgpICYmIHByb21pc2VCeUtleS5jaGlsZHJlbi5yZWFzb24oKTtcbiAgICAgICAgICAgICAgICBpZiAoY2hpbGRyZW5FcnJvcikge1xuICAgICAgICAgICAgICAgICAgdmFyIGNoaWxkcmVuRGlmZiA9IGNoaWxkcmVuRXJyb3IuZ2V0RGlmZihvdXRwdXQpO1xuICAgICAgICAgICAgICAgICAgaWYgKGNoaWxkcmVuRGlmZiAmJiBjaGlsZHJlbkRpZmYuaW5saW5lKSB7XG4gICAgICAgICAgICAgICAgICAgIG91dHB1dC5ubCgpLmluZGVudExpbmVzKCkuaSgpLmJsb2NrKGNoaWxkcmVuRGlmZi5kaWZmKS5ubCgpLm91dGRlbnRMaW5lcygpO1xuICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgb3V0cHV0Lm5sKCkuaW5kZW50TGluZXMoKS5pKCkuYmxvY2soZnVuY3Rpb24gKG91dHB1dCkge1xuICAgICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgc3ViamVjdC5jaGlsZE5vZGVzLmxlbmd0aDsgaSArPSAxKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXQuYXBwZW5kKGluc3BlY3Qoc3ViamVjdC5jaGlsZE5vZGVzW2ldKSkubmwoKTtcbiAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICBvdXRwdXQuc3AoKS5hbm5vdGF0aW9uQmxvY2soZnVuY3Rpb24gKG91dHB1dCkge1xuICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBvdXRwdXQuYXBwZW5kRXJyb3JNZXNzYWdlKGNoaWxkcmVuRXJyb3IpO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgb3V0cHV0Lm5sKCk7XG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgc3ViamVjdC5jaGlsZE5vZGVzLmxlbmd0aDsgaSArPSAxKSB7XG4gICAgICAgICAgICAgICAgICAgIG91dHB1dC5hcHBlbmQoaW5zcGVjdChzdWJqZWN0LmNoaWxkTm9kZXNbaV0pKTtcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgb3V0cHV0LmNvZGUoc3RyaW5naWZ5RW5kVGFnKHN1YmplY3QpLCAnaHRtbCcpO1xuICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgb3V0cHV0LmlubGluZSA9IHRydWU7XG4gICAgICAgICAgICAgIHJldHVybiBvdXRwdXQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgICAgfSk7XG4gICAgfSk7XG5cbiAgICBleHBlY3QuZXhwb3J0QXNzZXJ0aW9uKCc8RE9NRWxlbWVudD4gdG8gW29ubHldIGhhdmUgKGF0dHJpYnV0ZXxhdHRyaWJ1dGVzKSA8c3RyaW5nKz4nLCBmdW5jdGlvbiAoZXhwZWN0LCBzdWJqZWN0KSB7XG4gICAgICBm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KSkge1xuICAgICAgICAgICAgICAgICAgICB0b2tlbi5mb3JFYWNoKGZ1bmN0aW9uIChzdWJUb2tlbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRUb2tlbnMoc3ViVG9rZW4sIHBhcmVudFN0eWxlKTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgdG9rZW4gPT09ICdzdHJpbmcnKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciB1cHBlckNhbWVsQ2FzZWRQYXJlbnRTdHlsZSA9IHVwcGVyQ2FtZWxDYXNlKHBhcmVudFN0eWxlKTtcbiAgICAgICAgICAgICAgICAgICAgdG9rZW4gPSB0b2tlbi5yZXBsYWNlKC8mbHQ7L2csICc8Jyk7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGF0WydwcmlzbScgKyBjYXBpdGFsaXplZExhbmd1YWdlICsgdXBwZXJDYW1lbENhc2VkUGFyZW50U3R5bGVdKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGF0WydwcmlzbScgKyBjYXBpdGFsaXplZExhbmd1YWdlICsgdXBwZXJDYW1lbENhc2VkUGFyZW50U3R5bGVdKHRva2VuKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0aGF0WydwcmlzbScgKyB1cHBlckNhbWVsQ2FzZWRQYXJlbnRTdHlsZV0pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoYXRbJ3ByaXNtJyArIHVwcGVyQ2FtZWxDYXNlZFBhcmVudFN0eWxlXSh0b2tlbik7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobGFuZ3VhZ2VEZWZpbml0aW9uW3BhcmVudFN0eWxlXSAmJiBsYW5ndWFnZURlZmluaXRpb25bcGFyZW50U3R5bGVdLmFsaWFzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwcmludFRva2Vucyh0b2tlbiwgbGFuZ3VhZ2VE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ZGUoZWxlbWVudC50ZXh0Q29udGVudCwgdHlwZSkpO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChlbGVtZW50TmFtZSA9PT0gJ3N0eWxlJykge1xuICAgICAgICAgICAgICBpbnNwZWN0ZWRDaGlsZHJlbi5wdXNoKG91dHB1dC5jbG9uZSgpLmNvZGUoZWxlbWVudC50ZXh0Q29udGVudCwgZWxlbWVudC5nZXRBdHRyaWJ1dGUoJ3R5cGUnKSB8fCAndGV4dC9jc3MnKSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGVsZW1lbnQuY2hpbGROb2Rlcy5sZW5ndGg7IGkgKz0gMSkge1xuICAgICAgICAgICAgICAgIGluc3BlY3RlZENoaWxkcmVuLnB1c2goX2luc3BlY3Q1KGVsZW1lbnQuY2hpbGROb2Rlc1tpXSkpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHZhciB3aWR0aCA9IHN0YXJ0VGFnLmxlbmd0aDtcbiAgICAgICAgICAgIHZhciBtdWx0aXBsZUxpbmVzID0gaW5zcGVjdGVkQ2hpbGRyZW4uc29tZShmdW5jdGlvbiAobykge1xuICAgICAgICAgICAgICB2YXIgc2l6ZSA9IG8uc2l6ZSgpO1xuICAgICAgICAgICAgICB3aWR0aCArPSBzaXplLndpZHRoO1xuICAgICAgICAgICAgICByZXR1cm4gd2lkdGggPiA2MCB8fCBvLmhlaWdodCA+IDE7XG4gICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgaWYgKG11bHRpcGxlTGluZXMpIHtcbiAgICAgICAgICAgICAgb3V0cHV0Lm5sKCkuaW5kZW50TGluZXMoKTtcblxuICAgICAgICAgICAgICBpbnNwZWN0ZWRDaGlsZHJlbi5mb3JFYWNoKGZ1bmN0aW9uIChpbnNwZWN0ZWRDaGlsZCwgaW5kZXgpIHtcbiAgICAgICAgICAgICAgICBvdXRwdXQuaSg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IChvdXRwdXQpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gb3V0cHV0LmVycm9yKCdzaG91bGQgYmUgcmVtb3ZlZCcpO1xuICAgICAgICAgICAgICB9KS5ubCgpO1xuICAgICAgICAgICAgICBjYW5Db250aW51ZUxpbmUgPSBmYWxzZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9KTtcbiAgICAgICAgICBPYmplY3Qua2V5cyhleHBlY3RlZEF0dHJpYnV0ZXMpLmZvckVhY2goZnVuY3Rpb24gKGF0dHJpYnV0ZU5hbWUpIHtcbiAgICAgICAgICAgIG91dHB1dC5zcChjYW5Db250aW51ZUxpbmUgPyAxIDogMiArIGFjdHVhbC5ub2RlTmFtZS5sZW5ndGgpO1xuICAgICAgICAgICAgb3V0cHV0LmFubm90YXRpb25CbG9jayhmdW5jdGlvbiAob3V0cHV0KSB7XG4gICAgICAgICAgICAgIG91dHB1dC5lcnJvcignbWlzc2luZycpLnNwKCk7XG4gICAgICAgICAgICAgIHdyaXRlQXR0cmlidXRlVG9NYWdpY1BlbihvdXRwdXQsIGF0dHJpYnV0ZU5hbWUsIGV4cGVjdGVkQXR0cmlidXRlc1thdHRyaWJ1dGVOYW1lXSwgaXNIdG1sKTtcbiAgICAgICAgICAgIH0pLm5sKCk7XG4gICAgICAgICAgICBjYW5Db250aW51ZUxpbmUgPSBmYWxzZTtcbiAgICAgICAgICB9KTtcbiAgICAgICAgICBvdXRwdXQucHJpc21QdW5jdHVhdGlvbignPicpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIG91dHB1dC5jb2RlKHN0cmluZ2lmeVN0YXJ0VGFnKGFjdHVhbCksICdodG1sJyk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoIWVtcHR5RWxlbWVudHMpIHtcbiAgICAgICAgICBvdXRwdXQubmwoKS5pbmRlbnRMaW5lcygpLmkoKS5ibG9jayhfZGlmZjYobWFrZUF0dGFjaGVkRE9NTm9kZUxpc3QoYWN0dWFsLmN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AgICAgICAgICAgIGV4cGVjdGVkQ2xhc3NlcyA9IGdldENsYXNzTmFtZXNGcm9tQXR0cmlidXRlVmFsdWUoZXhwZWN0ZWRBdHRyaWJ1dGVWYWx1ZSk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgaWYgKG9ubHlBdHRyaWJ1dGVzKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGJ1YmJsZUVycm9yKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgIHJldHVybiBleHBlY3QoYWN0dWFsQ2xhc3Nlcy5zb3J0KCksICd0byBlcXVhbCcsIGV4cGVjdGVkQ2xhc3Nlcy5zb3J0KCkpO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmIChleHBlY3RlZENsYXNzZXMubGVuZ3RoID09PSAwKSB7XG4gICAgICAgICAgICAgICAgICByZXR1cm4gYnViYmxlRXJyb3IoZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZXhwZWN0KGV4cGVjdGVkQ2xhc3NlcywgJ3RvIGJlIGVtcHR5Jyk7XG4gICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIGJ1YmJsZUVycm9yKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgIHJldHVybiBleHBlY3QuYXBwbHkodW5kZWZpbmVkLCBbYWN0dWFsQ2xhc3NlcywgJ3RvIGNvbnRhaW4nXS5jb25jYXQoX3RvQ29uc3VtYWJsZUFycmF5KGV4cGVjdGVkQ2xhc3NlcykpKTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIGlmIChhdHRyaWJ1dGVOYW1lID09PSAnc3R5bGUnKSB7XG4gICAgICAgICAgICAgIHZhciBleHBlY3RlZFN0eWxlT2JqID0gdm9pZCAwO1xuICAgICAgICAgICAgICBpZiAodHlwZW9mIGV4cGVjdGVkVmFsdWVCeUF0dHJpYnV0ZU5hbWUuc3R5bGUgPT09ICdzdHJpbmcnKSB7XG4gICAgICAgICAgICAgICAgdmFsaWRhdGVTdHlsZXMoZXhwZWN0LCBleHBlY3RlZFZhbHVlQnlBdHRyaWJ1dGVOYW1lLnN0eWxlKTtcbiAgICAgICAgICAgICAgICBleHBlY3RlZFN0eWxlT2JqID0gc3R5bGVTdHJpbmdUb09iamVjdChleHBlY3RlZFZhbHVlQnlBdHRyaWJ1dGVOYW1lLnN0eWxlKTtcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBleHBlY3RlZFN0eWxlT2JqID0gZXhwZWN0ZWRWYWx1ZUJ5QXR0cmlidXRlTmFtZS5zdHlsZTtcbiAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgIGlmIChvbmx5QXR0cmlidXRlcykge1xuICAgICAgICAgICAgICAgIHJldHVybiBidWJibGVFcnJvcihmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICByZXR1cm4gZXhwZWN0KGF0dHJzLnN0eWxlLCAndG8gZXhoYXVzdGl2ZWx5IHNhdGlzZnknLCBleHBlY3RlZFN0eWxlT2JqKTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gYnViYmxlRXJyb3IoZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgcmV0dXJuIGV4cGVjdChhdHRycy5zdHlsZSwgJ3RvIHNhdGlzZnknLCBleHBlY3RlZFN0eWxlT2JqKTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgcmV0dXJuIGJ1YmJsZUVycm9yKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBy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xuXG4gICAgICByZXR1cm4gZXhwZWN0LnByb21pc2UuYWxsKHByb21pc2VCeUtleSkuY2F1Z2h0KGZ1bmN0aW9uICgpIHtcbiAgICAgICAgcmV0dXJuIGV4cGVjdC5wcm9taXNlLnNldHRsZShwcm9taXNlQnlLZXkpLnRoZW4oZnVuY3Rpb24gKCkge1xuICAgICAgICAgIGV4cGVjdC5mYWlsKHtcbiAgICAgICAgICAgIGRpZmY6IGZ1bmN0aW9uIGRpZmYob3V0cHV0LCBfZGlmZjcsIGluc3BlY3QsIGVxdWFsKSB7XG4gICAgICAgICAgICAgIG91dHB1dC5ibG9jayhmdW5jdGlvbiAob3V0cHV0KSB7XG4gICAgICAgICAgICAgICAgdmFyIHNlZW5FcnJvciA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIG91dHB1dC5wcmlzbVB1bmN0dWF0aW9uKCc8JykucHJpc21UYWcoaXNIdG1sID8gc3ViamVjdC5ub2RlTmFtZS50b0xvd2VyQ2FzZSgpIDogc3ViamVjdC5ub2RlTmFtZSk7XG4gICAgICAgICAgICAgICAgaWYgKHByb21pc2VCeUtleS5uYW1lLmlzUmVqZWN0ZWQoKSkge1xuICAgICAgICAgICAgICAgICAgc2VlbkVycm9yID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgIHZhciBuYW1lRXJyb3IgPSBwcm9taXNlQnlLZXkubmFtZS5yZWFzb24oKTtcbiAgICAgICAgICAgICAgICAgIG91dHB1dC5zcCgpLmFubm90YXRpb25CbG9jayhmdW5jdGlvbiAob3V0cHV0KSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBvdXRwdXQuZXJyb3IobmFtZUVycm9yICYmIG5hbWVFcnJvci5nZXRMYWJlbCgpIHx8ICdzaG91bGQgc2F0aXNmeScpLnNwKCkuYXBwZW5kKGluc3BlY3QodmFsdWUubmFtZSkpO1xuICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHZhciBpb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AgICAgICAgICAgICAgICAgIC8vIG9ubHlBdHRyaWJ1dGVzID09PSB0cnVlXG4gICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXQuZXJyb3IoJ3Nob3VsZCBiZSByZW1vdmVkJyk7XG4gICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgIGluc3BlY3RlZEF0dHJpYnV0ZXMucHVzaChhdHRyaWJ1dGVPdXRwdXQpO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIGV4cGVjdGVkQXR0cmlidXRlTmFtZXMuZm9yRWFjaChmdW5jdGlvbiAoYXR0cmlidXRlTmFtZSkge1xuICAgICAgICAgICAgICAgICAgaWYgKCFzdWJqZWN0Lmhhc0F0dHJpYnV0ZShhdHRyaWJ1dGVOYW1lKSkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgcHJvbWlzZSA9IHByb21pc2VCeUtleS5hdHRyaWJ1dGVzW2F0dHJpYnV0ZU5hbWVdO1xuICAgICAgICAgICAgICAgICAgICBpZiAoIXByb21pc2UgfHwgcHJvbWlzZS5pc1JlamVjdGVkKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICBzZWVuRXJyb3IgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgIHZhciBlcnIgPSBwcm9taXNlICYmIHByb21pc2UucmVhc29uKCk7XG4gICAgICAgICAgICAgICAgICAgICAgdmFyIGF0dHJpYnV0ZU91dHB1dCA9IG91dHB1dC5jbG9uZSgpLmFubm90YXRpb25CbG9jayhmdW5jdGlvbiAob3V0cHV0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXQuZXJyb3IoJ21pc3NpbmcnKS5zcCgpLnByaXNtQXR0ck5hbWUoYXR0cmlidXRlTmFtZSwgJ2h0bWwnKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChleHBlY3RlZFZhbHVlQnlBdHRyaWJ1dGVOYW1lW2F0dHJpYnV0ZU5hbWVdICE9PSB0cnVlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dC5zcCgpLmVycm9yKGVyciAmJiBlcnIuZ2V0TGFiZWwoKSB8fCAnc2hvdWxkIHNhdGlzZnknKS5zcCgpLmFwcGVuZChpbnNwZWN0KGV4cGVjdGVkVmFsdWVCeUF0dHJpYnV0ZU5hbWVbYXR0cmlidXRlTmFtZV0pKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICBpbnNwZWN0ZWRBdHRyaWJ1dGVzLnB1c2goYXR0cmlidXRlT3V0cHV0KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIGlmIChpbnNwZWN0ZWRBdHRyaWJ1dGVzLmxlbmd0aCA+IDApIHtcbiAgICAgICAgICAgICAgICAgIGlmIChzZWVuRXJyb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgb3V0cHV0Lm5sKCkuaW5kZW50TGluZXMoKS5pbmRlbnQoKS5ibG9jayhmdW5jdGlvbiAob3V0cHV0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgaW5zcGVjdGVkQXR0cmlidXRlcy5mb3JFYWNoKGZ1bmN0aW9uIChpdGVtLCBpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaSA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0Lm5sKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXQuYXBwZW5kKGl0ZW0pO1xuICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICB9KS5vdXRkZW50TGluZXMoKS5ubCgpO1xuICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgb3V0cHV0LnNwKCk7XG4gICAgICAgICAgICAgICAgICAgIGluc3BlY3RlZEF0dHJpYnV0ZXMuZm9yRWFjaChmdW5jdGlvbiAoaXRlbSwgaSkge1xuICAgICAgICAgICAgICAgICAgICAgIGlmIChpID4gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0LnNwKCk7XG4gICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgIG91dHB1dC5hcHBlbmQoaXRlbSk7XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoc2VlbkVycm9yKSB7XG4gICAgICAgICAgICAgICAgICAvLyBUaGUgdGFnIG5hbWUgbWlzbWF0Y2hlZFxuICAgICAgICAgICAgICAgICAgb3V0cHV0Lm5sKCk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgb3V0cHV0LnByaXNtUHVuY3R1YXRpb24oJz4nKTtcbiAgICAgICAgICAgICAgICB2YXIgY2hpbGRyZW5FcnJvciA9IHByb21pc2VCeUtleS5jaGlsZHJlbi5pc1JlamVjdGVkKCkgJiYgcHJvbWlzZUJ5S2V5LmNoaWxkcmVuLnJlYXNvbigpO1xuICAgICAgICAgICAgICAgIGlmIChjaGlsZHJlbkVycm9yKSB7XG4gICAgICAgICAgICAgICAgICB2YXIgY2hpbGRyZW5EaWZmID0gY2hpbGRyZW5FcnJvci5nZXREaWZmKG91dHB1dCk7XG4gICAgICAgICAgICAgICAgICBpZiAoY2hpbGRyZW5EaWZmICYmIGNoaWxkcmVuRGlmZi5pbmxpbmUpIHtcbiAgICAgICAgICAgICAgICAgICAgb3V0cHV0Lm5sKCkuaW5kZW50TGluZXMoKS5pKCkuYmxvY2soY2hpbGRyZW5EaWZmLmRpZmYpLm5sKCkub3V0ZGVudExpbmVzKCk7XG4gICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBvdXRwdXQubmwoKS5pbmRlbnRMaW5lcygpLmkoKS5ibG9jayhmdW5jdGlvbiAob3V0cHV0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBzdWJqZWN0LmNoaWxkTm9kZXMubGVuZ3RoOyBpICs9IDEpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dC5hcHBlbmQoaW5zcGVjdChzdWJqZWN0LmNoaWxkTm9kZXNbaV0pKS5ubCgpO1xuICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIG91dHB1dC5zcCgpLmFubm90YXRpb25CbG9jayhmdW5jdGlvbiAob3V0cHV0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG91dHB1dC5hcHBlbmRFcnJvck1lc3NhZ2UoY2hpbGRyZW5FcnJvcik7XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICBvdXRwdXQubmwoKTtcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBzdWJqZWN0LmNoaWxkTm9kZXMubGVuZ3RoOyBpICs9IDEpIHtcbiAgICAgICAgICAgICAgICAgICAgb3V0cHV0LmFwcGVuZChpbnNwZWN0KHN1YmplY3QuY2hpbGROb2Rlc1tpXSkpO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBvdXRwdXQuY29kZShzdHJpbmdpZnlFbmRUYWcoc3ViamVjdCksICdodG1sJyk7XG4gICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICBvdXRwdXQuaW5saW5lID0gdHJ1ZTtcbiAgICAgICAgIC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gICAgICAgICAgICAgICAgdGhhdFsncHJpc20nICsgdXBwZXJDYW1lbENhc2VkUGFyZW50U3R5bGVdKHRva2VuKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChsYW5ndWFnZURlZmluaXRpb25bcGFyZW50U3R5bGVdICYmIGxhbmd1YWdlRGVmaW5pdGlvbltwYXJlbnRTdHlsZV0uYWxpYXMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHByaW50VG9rZW5zKHRva2VuLCBsYW5ndWFnZURlZmluaXRpb25bcGFyZW50U3R5bGVdLmFsaWFzKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQudGV4dCh0b2tlbik7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBwcmludFRva2Vucyh0b2tlbi5jb250ZW50LCB0b2tlbi50eXBlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBwcmludFRva2VucyhwcmlzbS50b2tlbml6ZShzb3VyY2VUZXh0LCBwcmlzbS5sYW5ndWFnZXNbbGFuZ3VhZ2VdKSwgJ3RleHQnKTtcbiAgICAgICAgfSwgdHJ1ZSk7XG4gICAgfVxufTtcbiIsIm1vZHVsZS5leHBvcnRzPXtcbiAgXCJfZnJvbVwiOiBcIm1hZ2ljcGVuLXByaXNtQF4yLjMuMFwiLFxuICBcIl9pZFwiOiBcIm1hZ2ljcGVuLXByaXNtQDIuNC4wXCIsXG4gIFwiX2luQnVuZGxlXCI6IGZhbHNlLFxuICBcIl9pbnRlZ3JpdHlcIjogXCJzaGE1MTItT0VGWit4a3NKdFlnd25VNWpKcURYaGp2Z25TRmZNc1NnWHBKMldXUGFCSlVYTkt1UUIwRkJBaVF4alJLc1Y1Z250cGcvdGF6SDhMM2FwSng1ZU1kSmc9PVwiLFxuICBcIl9sb2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-dom.min.js +++ b/unexpected-dom.min.js @@ -1,2 +1,2 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.unexpected||(g.unexpected={})).dom=f()}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i"}var htmlDocument=getHtmlDocument(str);if(isFragment){var body=htmlDocument.body;var documentFragment=htmlDocument.createDocumentFragment();if(body){for(var i=0;i0){expect.errorMode="nested";expect.fail("Expectation contains invalid styles: {0}",invalidStyles.join(";"))}}function styleStringToObject(str){var styles={};str.split(";").forEach(function(rule){var tuple=rule.split(":").map(function(part){return part.trim()});if(tuple[0]&&tuple[1]){styles[tuple[0]]=tuple[1]}});return styles}function getClassNamesFromAttributeValue(attributeValue){if(attributeValue===null){return[]}if(attributeValue===""){return[]}var classNames=attributeValue.split(/\s+/);if(classNames.length===1&&classNames[0]===""){classNames.pop()}return classNames}function isInsideHtmlDocument(node){var ownerDocument=node.nodeType===9&&node.documentElement&&node.implementation?node:node.ownerDocument;if(ownerDocument.contentType){return ownerDocument.contentType==="text/html"}else{return ownerDocument.toString()==="[object HTMLDocument]"}}function getAttributes(element){var isHtml=isInsideHtmlDocument(element);var attrs=element.attributes;var result={};for(var i=0;i"}}module.exports={name:"unexpected-dom",installInto:function installInto(expect){expect=expect.child();expect.use(require("magicpen-prism"));function bubbleError(body){return expect.withError(body,function(err){err.errorMode="bubble";throw err})}expect.exportType({name:"DOMNode",base:"object",identify:function identify(obj){return obj&&obj.nodeName&&[2,3,4,5,6,7,10,11,12].indexOf(obj.nodeType)>-1},equal:function equal(a,b){return a.nodeValue===b.nodeValue},inspect:function inspect(element,depth,output){return output.code(element.nodeName+' "'+element.nodeValue+'"',"prism-string")}});expect.exportType({name:"DOMComment",base:"DOMNode",identify:function identify(obj){return obj&&typeof obj.nodeType==="number"&&obj.nodeType===8},equal:function equal(a,b){return a.nodeValue===b.nodeValue},inspect:function inspect(element,depth,output){return output.code("\x3c!--"+element.nodeValue+"--\x3e","html")},diff:function diff(actual,expected,output,_diff,inspect,equal){var d=_diff("\x3c!--"+actual.nodeValue+"--\x3e","\x3c!--"+expected.nodeValue+"--\x3e");d.inline=true;return d}});expect.exportType({name:"DOMIgnoreComment",base:"DOMComment",identify:function identify(obj){return this.baseType.identify(obj)&&/^\s*ignore\s*$/.test(obj.nodeValue)}});expect.exportType({name:"DOMTextNode",base:"DOMNode",identify:function identify(obj){return obj&&typeof obj.nodeType==="number"&&obj.nodeType===3},equal:function equal(a,b){return a.nodeValue===b.nodeValue},inspect:function inspect(element,depth,output){return output.code(entitify(element.nodeValue.trim()),"html")},diff:function diff(actual,expected,output,_diff2,inspect,equal){var d=_diff2(actual.nodeValue,expected.nodeValue);d.inline=true;return d}});expect.exportType({name:"DOMNodeList",base:"array-like",prefix:function prefix(output){return output.text("NodeList[")},suffix:function suffix(output){return output.text("]")},similar:function similar(a,b){return a.nodeType===1&&b.nodeType===1&&a.nodeName===b.nodeName},identify:function identify(obj){return obj&&typeof obj.length==="number"&&typeof obj.toString==="function"&&typeof obj.item==="function"&&(obj.toString().indexOf("NodeList")!==-1||obj.constructor&&obj.constructor.name==="NodeList")}});expect.exportType({name:"attachedDOMNodeList",base:"DOMNodeList",indent:false,prefix:function prefix(output){return output},suffix:function suffix(output){return output},delimiter:function delimiter(output){return output},identify:function identify(obj){return obj&&obj._isAttachedDOMNodeList}});function makeAttachedDOMNodeList(domNodeList,contentType){var attachedDOMNodeList=[];for(var i=0;i","html")},equal:function equal(a,b){return a.toString()===b.toString()},diff:function diff(actual,expected,output,_diff3){var d=_diff3("","");d.inline=true;return d}});expect.exportType({name:"DOMDocument",base:"DOMNode",identify:function identify(obj){return obj&&typeof obj.nodeType==="number"&&obj.nodeType===9&&obj.documentElement&&obj.implementation},inspect:function inspect(document,depth,output,_inspect2){for(var i=0;i',"xml");for(var i=0;i0){if(depth===1){output.text("...")}else{var inspectedChildren=[];if(elementName==="script"){var type=element.getAttribute("type");if(!type||/javascript/.test(type)){type="javascript"}inspectedChildren.push(output.clone().code(element.textContent,type))}else if(elementName==="style"){inspectedChildren.push(output.clone().code(element.textContent,element.getAttribute("type")||"text/css"))}else{for(var i=0;i60||o.height>1});if(multipleLines){output.nl().indentLines();inspectedChildren.forEach(function(inspectedChild,index){output.i().block(inspectedChild).nl()});output.outdentLines()}else{inspectedChildren.forEach(function(inspectedChild,index){return output.append(inspectedChild)})}}}output.code(stringifyEndTag(element),"html");return output},diffLimit:512,diff:function diff(actual,expected,output,_diff6,inspect,equal){var isHtml=isInsideHtmlDocument(actual);output.inline=true;if(Math.max(actual.length,expected.length)>this.diffLimit){output.jsComment("Diff suppressed due to size > "+this.diffLimit);return output}var emptyElements=actual.childNodes.length===0&&expected.childNodes.length===0;var conflictingElement=actual.nodeName.toLowerCase()!==expected.nodeName.toLowerCase()||!equal(getAttributes(actual),getAttributes(expected));if(conflictingElement){var canContinueLine=true;output.prismPunctuation("<").prismTag(actual.nodeName.toLowerCase());if(actual.nodeName.toLowerCase()!==expected.nodeName.toLowerCase()){output.sp().annotationBlock(function(output){return output.error("should be").sp().prismTag(expected.nodeName.toLowerCase())}).nl();canContinueLine=false}var actualAttributes=getAttributes(actual);var expectedAttributes=getAttributes(expected);Object.keys(actualAttributes).forEach(function(attributeName){output.sp(canContinueLine?1:2+actual.nodeName.length);writeAttributeToMagicPen(output,attributeName,actualAttributes[attributeName],isHtml);if(attributeName in expectedAttributes){if(actualAttributes[attributeName]===expectedAttributes[attributeName]){canContinueLine=true}else{output.sp().annotationBlock(function(output){return output.error("should equal").sp().append(inspect(entitify(expectedAttributes[attributeName])))}).nl();canContinueLine=false}delete expectedAttributes[attributeName]}else{output.sp().annotationBlock(function(output){return output.error("should be removed")}).nl();canContinueLine=false}});Object.keys(expectedAttributes).forEach(function(attributeName){output.sp(canContinueLine?1:2+actual.nodeName.length);output.annotationBlock(function(output){output.error("missing").sp();writeAttributeToMagicPen(output,attributeName,expectedAttributes[attributeName],isHtml)}).nl();canContinueLine=false});output.prismPunctuation(">")}else{output.code(stringifyStartTag(actual),"html")}if(!emptyElements){output.nl().indentLines().i().block(_diff6(makeAttachedDOMNodeList(actual.childNodes),makeAttachedDOMNodeList(expected.childNodes)).diff).nl().outdentLines()}output.code(stringifyEndTag(actual),"html");return output}});expect.exportAssertion(" to have (class|classes) ",function(expect,subject,value){return expect(subject,"to have attributes",{class:value})});expect.exportAssertion(" to only have (class|classes) ",function(expect,subject,value){return expect(subject,"to have attributes",{class:function _class(className){var actualClasses=getClassNamesFromAttributeValue(className);if(typeof value==="string"){value=getClassNamesFromAttributeValue(value)}return bubbleError(function(){return expect(actualClasses.sort(),"to equal",value.sort())})}})});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){return expect(subject.nodeValue,"to equal",value.nodeValue)});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){return expect(subject.nodeValue,"to equal",value.nodeValue)});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){return expect.fail()});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,_ref,value){var nodeValue=_ref.nodeValue;return expect(nodeValue,"to satisfy",value)});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,_ref2,value){var nodeValue=_ref2.nodeValue;return expect(nodeValue,"to satisfy",value)});function convertDOMNodeToSatisfySpec(node,isHtml){if(node.nodeType===10){return{name:node.nodeName}}else if(node.nodeType===1){var name=isHtml?node.nodeName.toLowerCase():node.nodeName;var result={name:name};if(node.attributes){result.attributes={};for(var i=0;i to [exhaustively] satisfy ",function(expect,subject,value){var isHtml=subject.ownerDocument.contentType==="text/html";expect.argsOutput=function(output){return output.code(value,isHtml?"html":"xml")};return expect(subject,"to [exhaustively] satisfy",(isHtml?parseHtml(value,true):parseXml(value)).childNodes)});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){var isHtml=subject.ownerDocument.contentType==="text/html";var satisfySpecs=[];for(var i=0;i to [exhaustively] satisfy ",function(expect,subject,value){var isHtml=isInsideHtmlDocument(subject);expect.argsOutput=function(output){return output.code(value,isHtml?"html":"xml")};return expect(subject,"to [exhaustively] satisfy",isHtml?parseHtml(value,true):parseXml(value))});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,_ref3){var childNodes=_ref3.childNodes;var isHtml=subject.ownerDocument.contentType==="text/html";return expect(subject,"to [exhaustively] satisfy",Array.prototype.map.call(childNodes,function(childNode){return convertDOMNodeToSatisfySpec(childNode,isHtml)}))});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,_ref4,value){var childNodes=_ref4.childNodes;return expect(childNodes,"to [exhaustively] satisfy",value)});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){var isHtml=isInsideHtmlDocument(subject);var documentFragment=isHtml?parseHtml(value,true):parseXml(value);if(documentFragment.childNodes.length!==1){throw new Error("HTMLElement to satisfy string: Only a single node is supported")}expect.argsOutput=function(output){return output.code(value,isHtml?"html":"xml")};return expect(subject,"to [exhaustively] satisfy",documentFragment.childNodes[0])});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){var isHtml=isInsideHtmlDocument(subject);var valueDocument=isHtml?parseHtml(value,false):parseXml(value);return expect(makeAttachedDOMNodeList(subject.childNodes),"to [exhaustively] satisfy",Array.prototype.map.call(valueDocument.childNodes,function(childNode){return convertDOMNodeToSatisfySpec(childNode,isHtml)}))});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,_ref5){var childNodes=_ref5.childNodes;var isHtml=isInsideHtmlDocument(subject);return expect(makeAttachedDOMNodeList(subject.childNodes),"to [exhaustively] satisfy",Array.prototype.map.call(childNodes,function(childNode){return convertDOMNodeToSatisfySpec(childNode,isHtml)}))});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){return expect(subject,"to [exhaustively] satisfy",convertDOMNodeToSatisfySpec(value,isInsideHtmlDocument(subject)))});expect.exportAssertion([" to [exhaustively] satisfy "," to [exhaustively] satisfy "," to [exhaustively] satisfy "],function(expect,subject,value){return expect.fail()});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){var isHtml=isInsideHtmlDocument(subject);var unsupportedOptions=Object.keys(value).filter(function(key){return key!=="attributes"&&key!=="name"&&key!=="children"&&key!=="onlyAttributes"&&key!=="textContent"});if(unsupportedOptions.length>0){throw new Error("Unsupported option"+(unsupportedOptions.length===1?"":"s")+": "+unsupportedOptions.join(", "))}var promiseByKey={name:expect.promise(function(){if(value&&typeof value.name!=="undefined"){return bubbleError(function(){return expect(isHtml?subject.nodeName.toLowerCase():subject.nodeName,"to satisfy",value.name)})}}),children:expect.promise(function(){if(typeof value.children!=="undefined"){if(typeof value.textContent!=="undefined"){throw new Error("The children and textContent properties are not supported together")}return bubbleError(function(){return expect(makeAttachedDOMNodeList(subject.childNodes,subject.ownerDocument.contentType),"to satisfy",value.children)})}else if(typeof value.textContent!=="undefined"){return bubbleError(function(){return expect(subject.textContent,"to satisfy",value.textContent)})}}),attributes:{}};var onlyAttributes=value&&value.onlyAttributes||expect.flags.exhaustively;var attrs=getAttributes(subject);var expectedAttributes=value&&value.attributes;var expectedAttributeNames=[];var expectedValueByAttributeName={};if(typeof expectedAttributes!=="undefined"){if(typeof expectedAttributes==="string"){expectedAttributes=[expectedAttributes]}if(Array.isArray(expectedAttributes)){expectedAttributes.forEach(function(attributeName){expectedValueByAttributeName[attributeName]=true})}else if(expectedAttributes&&(typeof expectedAttributes==="undefined"?"undefined":_typeof(expectedAttributes))==="object"){expectedValueByAttributeName=expectedAttributes}Object.keys(expectedValueByAttributeName).forEach(function(attributeName){expectedAttributeNames.push(attributeName)});expectedAttributeNames.forEach(function(attributeName){var attributeValue=subject.getAttribute(attributeName);var expectedAttributeValue=expectedValueByAttributeName[attributeName];promiseByKey.attributes[attributeName]=expect.promise(function(){if(typeof expectedAttributeValue==="undefined"){return bubbleError(function(){return expect(subject.hasAttribute(attributeName),"to be false")})}else if(isEnumeratedAttribute(attributeName)){var indexOfEnumeratedAttributeValue=enumeratedAttributeValues[attributeName].indexOf(expectedAttributeValue);return bubbleError(function(){if(indexOfEnumeratedAttributeValue===-1){expect.fail(function(output){return output.text("Invalid expected value ").appendInspected(expectedAttributeValue).text(". Supported values include: ").appendItems(enumeratedAttributeValues[attributeName],", ")})}expect(attributeValue,"to satisfy",expectedAttributeValue)})}else if(expectedAttributeValue===true){return bubbleError(function(){return expect(subject.hasAttribute(attributeName),"to be true")})}else if(attributeName==="class"&&(typeof expectedAttributeValue==="string"||Array.isArray(expectedAttributeValue))){var actualClasses=getClassNamesFromAttributeValue(attributeValue);var expectedClasses=expectedAttributeValue;if(typeof expectedClasses==="string"){expectedClasses=getClassNamesFromAttributeValue(expectedAttributeValue)}if(onlyAttributes){return bubbleError(function(){return expect(actualClasses.sort(),"to equal",expectedClasses.sort())})}else{if(expectedClasses.length===0){return bubbleError(function(){return expect(expectedClasses,"to be empty")})}return bubbleError(function(){return expect.apply(undefined,[actualClasses,"to contain"].concat(_toConsumableArray(expectedClasses)))})}}else if(attributeName==="style"){var expectedStyleObj=void 0;if(typeof expectedValueByAttributeName.style==="string"){validateStyles(expect,expectedValueByAttributeName.style);expectedStyleObj=styleStringToObject(expectedValueByAttributeName.style)}else{expectedStyleObj=expectedValueByAttributeName.style}if(onlyAttributes){return bubbleError(function(){return expect(attrs.style,"to exhaustively satisfy",expectedStyleObj)})}else{return bubbleError(function(){return expect(attrs.style,"to satisfy",expectedStyleObj)})}}else{return bubbleError(function(){return expect(attributeValue,"to satisfy",expectedAttributeValue)})}})});promiseByKey.attributePresence=expect.promise(function(){var attributeNamesExpectedToBeDefined=[];expectedAttributeNames.forEach(function(attributeName){if(typeof expectedValueByAttributeName[attributeName]==="undefined"){expect(attrs,"not to have key",attributeName)}else{attributeNamesExpectedToBeDefined.push(attributeName);expect(attrs,"to have key",attributeName)}});if(onlyAttributes){expect(Object.keys(attrs).sort(),"to equal",attributeNamesExpectedToBeDefined.sort())}})}return expect.promise.all(promiseByKey).caught(function(){return expect.promise.settle(promiseByKey).then(function(){expect.fail({diff:function diff(output,_diff7,inspect,equal){output.block(function(output){var seenError=false;output.prismPunctuation("<").prismTag(isHtml?subject.nodeName.toLowerCase():subject.nodeName);if(promiseByKey.name.isRejected()){seenError=true;var nameError=promiseByKey.name.reason();output.sp().annotationBlock(function(output){return output.error(nameError&&nameError.getLabel()||"should satisfy").sp().append(inspect(value.name))})}var inspectedAttributes=[];Object.keys(attrs).forEach(function(attributeName){var attributeOutput=output.clone();var promise=promiseByKey.attributes[attributeName];writeAttributeToMagicPen(attributeOutput,attributeName,attrs[attributeName],isHtml);if(promise&&promise.isFulfilled()||!promise&&(!onlyAttributes||expectedAttributeNames.indexOf(attributeName)!==-1)){}else{seenError=true;attributeOutput.sp().annotationBlock(function(output){if(promise&&typeof expectedValueByAttributeName[attributeName]!=="undefined"){output.appendErrorMessage(promise.reason())}else{output.error("should be removed")}})}inspectedAttributes.push(attributeOutput)});expectedAttributeNames.forEach(function(attributeName){if(!subject.hasAttribute(attributeName)){var promise=promiseByKey.attributes[attributeName];if(!promise||promise.isRejected()){seenError=true;var err=promise&&promise.reason();var attributeOutput=output.clone().annotationBlock(function(output){output.error("missing").sp().prismAttrName(attributeName,"html");if(expectedValueByAttributeName[attributeName]!==true){output.sp().error(err&&err.getLabel()||"should satisfy").sp().append(inspect(expectedValueByAttributeName[attributeName]))}});inspectedAttributes.push(attributeOutput)}}});if(inspectedAttributes.length>0){if(seenError){output.nl().indentLines().indent().block(function(output){inspectedAttributes.forEach(function(item,i){if(i>0){output.nl()}output.append(item)})}).outdentLines().nl()}else{output.sp();inspectedAttributes.forEach(function(item,i){if(i>0){output.sp()}output.append(item)})}}else if(seenError){output.nl()}output.prismPunctuation(">");var childrenError=promiseByKey.children.isRejected()&&promiseByKey.children.reason();if(childrenError){var childrenDiff=childrenError.getDiff(output);if(childrenDiff&&childrenDiff.inline){output.nl().indentLines().i().block(childrenDiff.diff).nl().outdentLines()}else{output.nl().indentLines().i().block(function(output){for(var i=0;i to [only] have (attribute|attributes) ",function(expect,subject){for(var _len=arguments.length,args=Array(_len>2?_len-2:0),_key=2;_key<_len;_key++){args[_key-2]=arguments[_key]}return expect(subject,"to [only] have attributes",args)});expect.exportAssertion(" not to have (attribute|attributes) ",function(expect,subject,value){var attributes=getAttributes(subject);value.forEach(function(name){delete attributes[name]});return expect(subject,"to only have attributes",attributes)});expect.exportAssertion(" not to have (attribute|attributes) ",function(expect,subject){for(var _len2=arguments.length,args=Array(_len2>2?_len2-2:0),_key2=2;_key2<_len2;_key2++){args[_key2-2]=arguments[_key2]}return expect(subject,"not to have attributes",args)});expect.exportAssertion(" to [only] have (attribute|attributes) ",function(expect,subject,value){return expect(subject,"to satisfy",{attributes:value,onlyAttributes:expect.flags.only})});expect.exportAssertion(" to have [no] (child|children)",function(expect,_ref6){var childNodes=_ref6.childNodes;return expect.flags.no?expect(childNodes,"to be empty"):expect(childNodes,"not to be empty")});expect.exportAssertion(" to have text ",function(expect,_ref7,value){var textContent=_ref7.textContent;return expect(textContent,"to satisfy",value)});expect.exportAssertion(" [when] queried for [first] ",function(expect,subject,query){var queryResult=void 0;expect.argsOutput[0]=function(output){return output.green(query)};expect.errorMode="nested";if(expect.flags.first){queryResult=subject.querySelector(query);if(!queryResult){expect.subjectOutput=function(output){return expect.inspect(subject,Infinity,output)};expect.fail(function(output){return output.error("The selector").sp().jsString(query).sp().error("yielded no results")})}}else{queryResult=subject.querySelectorAll(query);if(queryResult.length===0){expect.subjectOutput=function(output){return expect.inspect(subject,Infinity,output)};expect.fail(function(output){return output.error("The selector").sp().jsString(query).sp().error("yielded no results")})}}return expect.shift(queryResult)});expect.exportAssertion(" to contain [no] elements matching ",function(expect,subject,query){if(expect.flags.no){return expect(subject.querySelectorAll(query),"to satisfy",[])}expect.subjectOutput=function(output){return expect.inspect(subject,Infinity,output)};return expect(subject.querySelectorAll(query),"not to satisfy",[])});expect.exportAssertion(" [not] to match ",function(expect,subject,query){expect.subjectOutput=function(output){return expect.inspect(subject,Infinity,output)};return expect(matchesSelector(subject,query),"[not] to be true")}) +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.unexpected||(g.unexpected={})).dom=f()}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i"}var htmlDocument=getHtmlDocument(str);if(isFragment){var body=htmlDocument.body;var documentFragment=htmlDocument.createDocumentFragment();if(body){for(var i=0;i0){expect.errorMode="nested";expect.fail("Expectation contains invalid styles: {0}",invalidStyles.join(";"))}}function styleStringToObject(str){var styles={};str.split(";").forEach(function(rule){var tuple=rule.split(":").map(function(part){return part.trim()});if(tuple[0]&&tuple[1]){styles[tuple[0]]=tuple[1]}});return styles}function getClassNamesFromAttributeValue(attributeValue){if(attributeValue===null){return[]}if(attributeValue===""){return[]}var classNames=attributeValue.split(/\s+/);if(classNames.length===1&&classNames[0]===""){classNames.pop()}return classNames}function isInsideHtmlDocument(node){var ownerDocument=node.nodeType===9&&node.documentElement&&node.implementation?node:node.ownerDocument;if(ownerDocument.contentType){return ownerDocument.contentType==="text/html"}else{return ownerDocument.toString()==="[object HTMLDocument]"}}function getAttributes(element){var isHtml=isInsideHtmlDocument(element);var attrs=element.attributes;var result={};for(var i=0;i"}}module.exports={name:"unexpected-dom",installInto:function installInto(expect){expect=expect.child();expect.use(require("magicpen-prism"));function bubbleError(body){return expect.withError(body,function(err){err.errorMode="bubble";throw err})}expect.exportType({name:"DOMNode",base:"object",identify:function identify(obj){return obj&&obj.nodeName&&[2,3,4,5,6,7,10,11,12].indexOf(obj.nodeType)>-1},equal:function equal(a,b){return a.nodeValue===b.nodeValue},inspect:function inspect(element,depth,output){return output.code(element.nodeName+' "'+element.nodeValue+'"',"prism-string")}});expect.exportType({name:"DOMComment",base:"DOMNode",identify:function identify(obj){return obj&&typeof obj.nodeType==="number"&&obj.nodeType===8},equal:function equal(a,b){return a.nodeValue===b.nodeValue},inspect:function inspect(element,depth,output){return output.code("\x3c!--"+element.nodeValue+"--\x3e","html")},diff:function diff(actual,expected,output,_diff,inspect,equal){var d=_diff("\x3c!--"+actual.nodeValue+"--\x3e","\x3c!--"+expected.nodeValue+"--\x3e");d.inline=true;return d}});expect.exportType({name:"DOMIgnoreComment",base:"DOMComment",identify:function identify(obj){return this.baseType.identify(obj)&&/^\s*ignore\s*$/.test(obj.nodeValue)}});expect.exportType({name:"DOMTextNode",base:"DOMNode",identify:function identify(obj){return obj&&typeof obj.nodeType==="number"&&obj.nodeType===3},equal:function equal(a,b){return a.nodeValue===b.nodeValue},inspect:function inspect(element,depth,output){return output.code(entitify(element.nodeValue.trim()),"html")},diff:function diff(actual,expected,output,_diff2,inspect,equal){var d=_diff2(actual.nodeValue,expected.nodeValue);d.inline=true;return d}});expect.exportType({name:"DOMNodeList",base:"array-like",prefix:function prefix(output){return output.text("NodeList[")},suffix:function suffix(output){return output.text("]")},similar:function similar(a,b){return a.nodeType===1&&b.nodeType===1&&a.nodeName===b.nodeName},identify:function identify(obj){return obj&&typeof obj.length==="number"&&typeof obj.toString==="function"&&typeof obj.item==="function"&&(obj.toString().indexOf("NodeList")!==-1||obj.constructor&&obj.constructor.name==="NodeList")}});expect.exportType({name:"attachedDOMNodeList",base:"DOMNodeList",indent:false,prefix:function prefix(output){return output},suffix:function suffix(output){return output},delimiter:function delimiter(output){return output},identify:function identify(obj){return obj&&obj._isAttachedDOMNodeList}});function makeAttachedDOMNodeList(domNodeList,contentType){var attachedDOMNodeList=[];for(var i=0;i","html")},equal:function equal(a,b){return a.toString()===b.toString()},diff:function diff(actual,expected,output,_diff3){var d=_diff3("","");d.inline=true;return d}});expect.exportType({name:"DOMDocument",base:"DOMNode",identify:function identify(obj){return obj&&typeof obj.nodeType==="number"&&obj.nodeType===9&&obj.documentElement&&obj.implementation},inspect:function inspect(document,depth,output,_inspect2){for(var i=0;i',"xml");for(var i=0;i0){if(depth===1){output.text("...")}else{var inspectedChildren=[];if(elementName==="script"){var type=element.getAttribute("type");if(!type||/javascript/.test(type)){type="javascript"}inspectedChildren.push(output.clone().code(element.textContent,type))}else if(elementName==="style"){inspectedChildren.push(output.clone().code(element.textContent,element.getAttribute("type")||"text/css"))}else{for(var i=0;i60||o.height>1});if(multipleLines){output.nl().indentLines();inspectedChildren.forEach(function(inspectedChild,index){output.i().block(inspectedChild).nl()});output.outdentLines()}else{inspectedChildren.forEach(function(inspectedChild,index){return output.append(inspectedChild)})}}}output.code(stringifyEndTag(element),"html");return output},diffLimit:512,diff:function diff(actual,expected,output,_diff6,inspect,equal){var isHtml=isInsideHtmlDocument(actual);output.inline=true;if(Math.max(actual.length,expected.length)>this.diffLimit){output.jsComment("Diff suppressed due to size > "+this.diffLimit);return output}var emptyElements=actual.childNodes.length===0&&expected.childNodes.length===0;var conflictingElement=actual.nodeName.toLowerCase()!==expected.nodeName.toLowerCase()||!equal(getAttributes(actual),getAttributes(expected));if(conflictingElement){var canContinueLine=true;output.prismPunctuation("<").prismTag(actual.nodeName.toLowerCase());if(actual.nodeName.toLowerCase()!==expected.nodeName.toLowerCase()){output.sp().annotationBlock(function(output){return output.error("should be").sp().prismTag(expected.nodeName.toLowerCase())}).nl();canContinueLine=false}var actualAttributes=getAttributes(actual);var expectedAttributes=getAttributes(expected);Object.keys(actualAttributes).forEach(function(attributeName){output.sp(canContinueLine?1:2+actual.nodeName.length);writeAttributeToMagicPen(output,attributeName,actualAttributes[attributeName],isHtml);if(attributeName in expectedAttributes){if(actualAttributes[attributeName]===expectedAttributes[attributeName]){canContinueLine=true}else{output.sp().annotationBlock(function(output){return output.error("should equal").sp().append(inspect(entitify(expectedAttributes[attributeName])))}).nl();canContinueLine=false}delete expectedAttributes[attributeName]}else{output.sp().annotationBlock(function(output){return output.error("should be removed")}).nl();canContinueLine=false}});Object.keys(expectedAttributes).forEach(function(attributeName){output.sp(canContinueLine?1:2+actual.nodeName.length);output.annotationBlock(function(output){output.error("missing").sp();writeAttributeToMagicPen(output,attributeName,expectedAttributes[attributeName],isHtml)}).nl();canContinueLine=false});output.prismPunctuation(">")}else{output.code(stringifyStartTag(actual),"html")}if(!emptyElements){output.nl().indentLines().i().block(_diff6(makeAttachedDOMNodeList(actual.childNodes),makeAttachedDOMNodeList(expected.childNodes)).diff).nl().outdentLines()}output.code(stringifyEndTag(actual),"html");return output}});expect.exportAssertion(" to have (class|classes) ",function(expect,subject,value){return expect(subject,"to have attributes",{class:value})});expect.exportAssertion(" to only have (class|classes) ",function(expect,subject,value){return expect(subject,"to have attributes",{class:function _class(className){var actualClasses=getClassNamesFromAttributeValue(className);if(typeof value==="string"){value=getClassNamesFromAttributeValue(value)}return bubbleError(function(){return expect(actualClasses.sort(),"to equal",value.sort())})}})});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){return expect(subject.nodeValue,"to equal",value.nodeValue)});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){return expect(subject.nodeValue,"to equal",value.nodeValue)});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){return expect.fail()});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,_ref,value){var nodeValue=_ref.nodeValue;return expect(nodeValue,"to satisfy",value)});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,_ref2,value){var nodeValue=_ref2.nodeValue;return expect(nodeValue,"to satisfy",value)});function convertDOMNodeToSatisfySpec(node,isHtml){if(node.nodeType===10){return{name:node.nodeName}}else if(node.nodeType===1){var name=isHtml?node.nodeName.toLowerCase():node.nodeName;var result={name:name};if(node.attributes){result.attributes={};for(var i=0;i to [exhaustively] satisfy ",function(expect,subject,value){var isHtml=subject.ownerDocument.contentType==="text/html";expect.argsOutput=function(output){return output.code(value,isHtml?"html":"xml")};return expect(subject,"to [exhaustively] satisfy",(isHtml?parseHtml(value,true):parseXml(value)).childNodes)});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){var isHtml=subject.ownerDocument.contentType==="text/html";var satisfySpecs=[];for(var i=0;i to [exhaustively] satisfy ",function(expect,subject,value){var isHtml=isInsideHtmlDocument(subject);expect.argsOutput=function(output){return output.code(value,isHtml?"html":"xml")};return expect(subject,"to [exhaustively] satisfy",isHtml?parseHtml(value,true):parseXml(value))});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,_ref3){var childNodes=_ref3.childNodes;var isHtml=subject.ownerDocument.contentType==="text/html";return expect(subject,"to [exhaustively] satisfy",Array.prototype.map.call(childNodes,function(childNode){return convertDOMNodeToSatisfySpec(childNode,isHtml)}))});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,_ref4,value){var childNodes=_ref4.childNodes;return expect(childNodes,"to [exhaustively] satisfy",value)});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){var isHtml=isInsideHtmlDocument(subject);var documentFragment=isHtml?parseHtml(value,true):parseXml(value);if(documentFragment.childNodes.length!==1){throw new Error("HTMLElement to satisfy string: Only a single node is supported")}expect.argsOutput=function(output){return output.code(value,isHtml?"html":"xml")};return expect(subject,"to [exhaustively] satisfy",documentFragment.childNodes[0])});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){var isHtml=isInsideHtmlDocument(subject);var valueDocument=isHtml?parseHtml(value,false):parseXml(value);return expect(makeAttachedDOMNodeList(subject.childNodes),"to [exhaustively] satisfy",Array.prototype.map.call(valueDocument.childNodes,function(childNode){return convertDOMNodeToSatisfySpec(childNode,isHtml)}))});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,_ref5){var childNodes=_ref5.childNodes;var isHtml=isInsideHtmlDocument(subject);return expect(makeAttachedDOMNodeList(subject.childNodes),"to [exhaustively] satisfy",Array.prototype.map.call(childNodes,function(childNode){return convertDOMNodeToSatisfySpec(childNode,isHtml)}))});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){return expect(subject,"to [exhaustively] satisfy",convertDOMNodeToSatisfySpec(value,isInsideHtmlDocument(subject)))});expect.exportAssertion([" to [exhaustively] satisfy "," to [exhaustively] satisfy "," to [exhaustively] satisfy "],function(expect,subject,value){return expect.fail()});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){var isHtml=isInsideHtmlDocument(subject);var unsupportedOptions=Object.keys(value).filter(function(key){return key!=="attributes"&&key!=="name"&&key!=="children"&&key!=="onlyAttributes"&&key!=="textContent"});if(unsupportedOptions.length>0){throw new Error("Unsupported option"+(unsupportedOptions.length===1?"":"s")+": "+unsupportedOptions.join(", "))}var promiseByKey={name:expect.promise(function(){if(value&&typeof value.name!=="undefined"){return bubbleError(function(){return expect(isHtml?subject.nodeName.toLowerCase():subject.nodeName,"to satisfy",value.name)})}}),children:expect.promise(function(){if(typeof value.children!=="undefined"){if(typeof value.textContent!=="undefined"){throw new Error("The children and textContent properties are not supported together")}return bubbleError(function(){return expect(makeAttachedDOMNodeList(subject.childNodes,subject.ownerDocument.contentType),"to satisfy",value.children)})}else if(typeof value.textContent!=="undefined"){return bubbleError(function(){return expect(subject.textContent,"to satisfy",value.textContent)})}}),attributes:{}};var onlyAttributes=value&&value.onlyAttributes||expect.flags.exhaustively;var attrs=getAttributes(subject);var expectedAttributes=value&&value.attributes;var expectedAttributeNames=[];var expectedValueByAttributeName={};if(typeof expectedAttributes!=="undefined"){if(typeof expectedAttributes==="string"){expectedAttributes=[expectedAttributes]}if(Array.isArray(expectedAttributes)){expectedAttributes.forEach(function(attributeName){expectedValueByAttributeName[attributeName]=true})}else if(expectedAttributes&&(typeof expectedAttributes==="undefined"?"undefined":_typeof(expectedAttributes))==="object"){expectedValueByAttributeName=expectedAttributes}Object.keys(expectedValueByAttributeName).forEach(function(attributeName){expectedAttributeNames.push(attributeName)});expectedAttributeNames.forEach(function(attributeName){var attributeValue=subject.getAttribute(attributeName);var expectedAttributeValue=expectedValueByAttributeName[attributeName];promiseByKey.attributes[attributeName]=expect.promise(function(){if(typeof expectedAttributeValue==="undefined"){return bubbleError(function(){return expect(subject.hasAttribute(attributeName),"to be false")})}else if(isEnumeratedAttribute(attributeName)){var indexOfEnumeratedAttributeValue=enumeratedAttributeValues[attributeName].indexOf(expectedAttributeValue);return bubbleError(function(){if(indexOfEnumeratedAttributeValue===-1){expect.fail(function(output){return output.text("Invalid expected value ").appendInspected(expectedAttributeValue).text(". Supported values include: ").appendItems(enumeratedAttributeValues[attributeName],", ")})}expect(attributeValue,"to satisfy",expectedAttributeValue)})}else if(expectedAttributeValue===true){return bubbleError(function(){return expect(subject.hasAttribute(attributeName),"to be true")})}else if(attributeName==="class"&&(typeof expectedAttributeValue==="string"||Array.isArray(expectedAttributeValue))){var actualClasses=getClassNamesFromAttributeValue(attributeValue);var expectedClasses=expectedAttributeValue;if(typeof expectedClasses==="string"){expectedClasses=getClassNamesFromAttributeValue(expectedAttributeValue)}if(onlyAttributes){return bubbleError(function(){return expect(actualClasses.sort(),"to equal",expectedClasses.sort())})}else{if(expectedClasses.length===0){return bubbleError(function(){return expect(expectedClasses,"to be empty")})}return bubbleError(function(){return expect.apply(undefined,[actualClasses,"to contain"].concat(_toConsumableArray(expectedClasses)))})}}else if(attributeName==="style"){var expectedStyleObj=void 0;if(typeof expectedValueByAttributeName.style==="string"){validateStyles(expect,expectedValueByAttributeName.style);expectedStyleObj=styleStringToObject(expectedValueByAttributeName.style)}else{expectedStyleObj=expectedValueByAttributeName.style}if(onlyAttributes){return bubbleError(function(){return expect(attrs.style,"to exhaustively satisfy",expectedStyleObj)})}else{return bubbleError(function(){return expect(attrs.style,"to satisfy",expectedStyleObj)})}}else{return bubbleError(function(){return expect(attributeValue,"to satisfy",expectedAttributeValue)})}})});promiseByKey.attributePresence=expect.promise(function(){var attributeNamesExpectedToBeDefined=[];expectedAttributeNames.forEach(function(attributeName){if(typeof expectedValueByAttributeName[attributeName]==="undefined"){expect(attrs,"not to have key",attributeName)}else{attributeNamesExpectedToBeDefined.push(attributeName);expect(attrs,"to have key",attributeName)}});if(onlyAttributes){expect(Object.keys(attrs).sort(),"to equal",attributeNamesExpectedToBeDefined.sort())}})}return expect.promise.all(promiseByKey).caught(function(){return expect.promise.settle(promiseByKey).then(function(){expect.fail({diff:function diff(output,_diff7,inspect,equal){output.block(function(output){var seenError=false;output.prismPunctuation("<").prismTag(isHtml?subject.nodeName.toLowerCase():subject.nodeName);if(promiseByKey.name.isRejected()){seenError=true;var nameError=promiseByKey.name.reason();output.sp().annotationBlock(function(output){return output.error(nameError&&nameError.getLabel()||"should satisfy").sp().append(inspect(value.name))})}var inspectedAttributes=[];Object.keys(attrs).forEach(function(attributeName){var attributeOutput=output.clone();var promise=promiseByKey.attributes[attributeName];writeAttributeToMagicPen(attributeOutput,attributeName,attrs[attributeName],isHtml);if(promise&&promise.isFulfilled()||!promise&&(!onlyAttributes||expectedAttributeNames.indexOf(attributeName)!==-1)){}else{seenError=true;attributeOutput.sp().annotationBlock(function(output){if(promise&&typeof expectedValueByAttributeName[attributeName]!=="undefined"){output.appendErrorMessage(promise.reason())}else{output.error("should be removed")}})}inspectedAttributes.push(attributeOutput)});expectedAttributeNames.forEach(function(attributeName){if(!subject.hasAttribute(attributeName)){var promise=promiseByKey.attributes[attributeName];if(!promise||promise.isRejected()){seenError=true;var err=promise&&promise.reason();var attributeOutput=output.clone().annotationBlock(function(output){output.error("missing").sp().prismAttrName(attributeName,"html");if(expectedValueByAttributeName[attributeName]!==true){output.sp().error(err&&err.getLabel()||"should satisfy").sp().append(inspect(expectedValueByAttributeName[attributeName]))}});inspectedAttributes.push(attributeOutput)}}});if(inspectedAttributes.length>0){if(seenError){output.nl().indentLines().indent().block(function(output){inspectedAttributes.forEach(function(item,i){if(i>0){output.nl()}output.append(item)})}).outdentLines().nl()}else{output.sp();inspectedAttributes.forEach(function(item,i){if(i>0){output.sp()}output.append(item)})}}else if(seenError){output.nl()}output.prismPunctuation(">");var childrenError=promiseByKey.children.isRejected()&&promiseByKey.children.reason();if(childrenError){var childrenDiff=childrenError.getDiff(output);if(childrenDiff&&childrenDiff.inline){output.nl().indentLines().i().block(childrenDiff.diff).nl().outdentLines()}else{output.nl().indentLines().i().block(function(output){for(var i=0;i to [only] have (attribute|attributes) ",function(expect,subject){for(var _len=arguments.length,args=Array(_len>2?_len-2:0),_key=2;_key<_len;_key++){args[_key-2]=arguments[_key]}return expect(subject,"to [only] have attributes",args)});expect.exportAssertion(" not to have (attribute|attributes) ",function(expect,subject,value){var attributes=getAttributes(subject);value.forEach(function(name){delete attributes[name]});return expect(subject,"to only have attributes",attributes)});expect.exportAssertion(" not to have (attribute|attributes) ",function(expect,subject){for(var _len2=arguments.length,args=Array(_len2>2?_len2-2:0),_key2=2;_key2<_len2;_key2++){args[_key2-2]=arguments[_key2]}return expect(subject,"not to have attributes",args)});expect.exportAssertion(" to [only] have (attribute|attributes) ",function(expect,subject,value){return expect(subject,"to satisfy",{attributes:value,onlyAttributes:expect.flags.only})});expect.exportAssertion(" to have [no] (child|children)",function(expect,_ref6){var childNodes=_ref6.childNodes;return expect.flags.no?expect(childNodes,"to be empty"):expect(childNodes,"not to be empty")});expect.exportAssertion(" to have text ",function(expect,_ref7,value){var textContent=_ref7.textContent;return expect(textContent,"to satisfy",value)});expect.exportAssertion(" [when] queried for [first] ",function(expect,subject,query){var queryResult=void 0;expect.argsOutput[0]=function(output){return output.green(query)};expect.errorMode="nested";if(expect.flags.first){queryResult=subject.querySelector(query);if(!queryResult){expect.subjectOutput=function(output){return expect.inspect(subject,Infinity,output)};expect.fail(function(output){return output.error("The selector").sp().jsString(query).sp().error("yielded no results")})}}else{queryResult=subject.querySelectorAll(query);if(queryResult.length===0){expect.subjectOutput=function(output){return expect.inspect(subject,Infinity,output)};expect.fail(function(output){return output.error("The selector").sp().jsString(query).sp().error("yielded no results")})}}return expect.shift(queryResult)});expect.exportAssertion(" to contain [no] elements matching ",function(expect,subject,query){if(expect.flags.no){return expect(subject.querySelectorAll(query),"to satisfy",[])}expect.subjectOutput=function(output){return expect.inspect(subject,Infinity,output)};return expect(subject.querySelectorAll(query),"not to satisfy",[])});expect.exportAssertion(" [not] to match ",function(expect,subject,query){expect.subjectOutput=function(output){return expect.inspect(subject,Infinity,output)};return expect(matchesSelector(subject,query),"[not] to be true")}) ;expect.exportAssertion(" [when] parsed as (html|HTML) [fragment] ",function(expect,subject){expect.errorMode="nested";return expect.shift(parseHtml(subject,expect.flags.fragment))});expect.exportAssertion(" [when] parsed as (xml|XML) ",function(expect,subject){expect.errorMode="nested";return expect.shift(parseXml(subject))})}}},{"./matchesSelector":2,"magicpen-prism":3}],2:[function(require,module,exports){"use strict";module.exports=function(elm,selector){var matchFuntion=elm.matchesSelector||elm.mozMatchesSelector||elm.msMatchesSelector||elm.oMatchesSelector||elm.webkitMatchesSelector||function(selector){var node=this;var nodes=(node.parentNode||node.document).querySelectorAll(selector);var i=0;while(nodes[i]&&nodes[i]!==node){i+=1}return!!nodes[i]};return matchFuntion.call(elm,selector)}},{}],3:[function(require,module,exports){(function(global){var oldPrismGlobal=global.Prism;var prism=global.Prism=require("prismjs");require("prismjs/components/prism-graphql.js");require("prismjs/components/prism-csp.js");global.Prism=oldPrismGlobal;var defaultTheme={prismComment:"#708090",prismProlog:"prismComment",prismDoctype:"prismComment",prismCdata:"prismComment",prismPunctuation:"#999",prismSymbol:"#905",prismProperty:"prismSymbol",prismTag:"prismSymbol",prismBoolean:"prismSymbol",prismNumber:"prismSymbol",prismConstant:"prismSymbol",prismDeleted:"prismSymbol",prismString:"#690",prismSelector:"prismString",prismAttrName:"prismString",prismChar:"prismString",prismBuiltin:"prismString",prismInserted:"prismString",prismOperator:"#a67f59",prismVariable:"prismOperator",prismEntity:"prismOperator",prismUrl:"prismOperator",prismCssString:"prismOperator",prismKeyword:"#07a",prismAtrule:"prismKeyword",prismAttrValue:"prismKeyword",prismFunction:"#DD4A68",prismRegex:"#e90",prismImportant:["#e90","bold"]};var languageMapping={"text/html":"markup","application/xml":"markup","text/xml":"markup","application/json":"javascript","text/javascript":"javascript","application/javascript":"javascript","text/css":"css",html:"markup",xml:"markup",c:"clike","c++":"clike",cpp:"clike","c#":"clike",java:"clike","application/graphql":"graphql"};function upperCamelCase(str){return str.replace(/(?:^|-)([a-z])/g,function($0,ch){return ch.toUpperCase()})}module.exports={name:"magicpen-prism",version:require("../package.json").version,installInto:function(magicPen){magicPen.installTheme(defaultTheme);magicPen.addStyle("code",function(sourceText,language){if(language in languageMapping){language=languageMapping[language]}else if(/\+xml\b/.test(language)){language="markup"}if(!(language in prism.languages)){return this.text(sourceText)}var that=this;var capitalizedLanguage=upperCamelCase(language);var languageDefinition=prism.languages[language];function printTokens(token,parentStyle){if(Array.isArray(token)){token.forEach(function(subToken){printTokens(subToken,parentStyle)})}else if(typeof token==="string"){var upperCamelCasedParentStyle=upperCamelCase(parentStyle);token=token.replace(/</g,"<");if(that["prism"+capitalizedLanguage+upperCamelCasedParentStyle]){that["prism"+capitalizedLanguage+upperCamelCasedParentStyle](token)}else if(that["prism"+upperCamelCasedParentStyle]){that["prism"+upperCamelCasedParentStyle](token)}else if(languageDefinition[parentStyle]&&languageDefinition[parentStyle].alias){printTokens(token,languageDefinition[parentStyle].alias)}else{that.text(token)}}else{printTokens(token.content,token.type)}}printTokens(prism.tokenize(sourceText,prism.languages[language]),"text")},true)}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"../package.json":4,prismjs:7,"prismjs/components/prism-csp.js":5,"prismjs/components/prism-graphql.js":6}],4:[function(require,module,exports){module.exports={_from:"magicpen-prism@^2.3.0",_id:"magicpen-prism@2.4.0",_inBundle:false,_integrity:"sha512-OEFZ+xksJtYgwnU5jJqDXhjvgnSFfMsSgXpJ2WWPaBJUXNKuQB0FBAiQxjRKsV5gntpg/tazH8L3apJx5eMdJg==",_location:"/magicpen-prism",_phantomChildren:{},_requested:{type:"range",registry:true,raw:"magicpen-prism@^2.3.0",name:"magicpen-prism",escapedName:"magicpen-prism",rawSpec:"^2.3.0",saveSpec:null,fetchSpec:"^2.3.0"},_requiredBy:["/","/unexpected-markdown"],_resolved:"https://registry.npmjs.org/magicpen-prism/-/magicpen-prism-2.4.0.tgz",_shasum:"aa79ca9b656f35069ad0aea8b102f1ac8642cbb0",_spec:"magicpen-prism@^2.3.0",_where:"/Users/ssimonsen/Code/unexpected-dom",author:{name:"Andreas Lind",email:"andreas@one.com"},bugs:{url:"https://github.com/unexpectedjs/magicpen-prism/issues"},bundleDependencies:false,dependencies:{prismjs:"1.11.0"},deprecated:false,description:"Add syntax highlighting support to magicpen via prism.js",devDependencies:{browserify:"13.0.0","bundle-collapser":"1.2.1",eslint:"2.13.1","eslint-config-onelint":"1.2.0",magicpen:"5.9.0",mocha:"2.4.5",unexpected:"10.10.5"},files:["lib","magicPenPrism.min.js"],homepage:"https://github.com/unexpectedjs/magicpen-prism#readme",main:"lib/magicPenPrism.js",name:"magicpen-prism",repository:{type:"git",url:"git+https://github.com/unexpectedjs/magicpen-prism.git"},scripts:{lint:"eslint .",prepublish:"browserify -p bundle-collapser/plugin -e lib/magicPenPrism -s magicPenPrism > magicPenPrism.min.js",test:"mocha",travis:"npm run lint && npm test"},version:"2.4.0"}},{}],5:[function(require,module,exports){Prism.languages.csp={directive:{pattern:/\b(?:(?:base-uri|form-action|frame-ancestors|plugin-types|referrer|reflected-xss|report-to|report-uri|require-sri-for|sandbox) |(?:block-all-mixed-content|disown-opener|upgrade-insecure-requests)(?: |;)|(?:child|connect|default|font|frame|img|manifest|media|object|script|style|worker)-src )/i,alias:"keyword"},safe:{pattern:/'(?:self|none|strict-dynamic|(?:nonce-|sha(?:256|384|512)-)[a-zA-Z0-9+=\/]+)'/,alias:"selector"},unsafe:{pattern:/(?:'unsafe-inline'|'unsafe-eval'|'unsafe-hashed-attributes'|\*)/,alias:"function"}}},{}],6:[function(require,module,exports){Prism.languages.graphql={comment:/#.*/,string:{pattern:/"(?:\\.|[^\\"\r\n])*"/,greedy:true},number:/(?:\B-|\b)\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/,boolean:/\b(?:true|false)\b/,variable:/\$[a-z_]\w*/i,directive:{pattern:/@[a-z_]\w*/i,alias:"function"},"attr-name":/[a-z_]\w*(?=\s*:)/i,keyword:[{pattern:/(fragment\s+(?!on)[a-z_]\w*\s+|\.{3}\s*)on\b/,lookbehind:true},/\b(?:query|fragment|mutation)\b/],operator:/!|=|\.{3}/,punctuation:/[!(){}\[\]:=,]/}},{}],7:[function(require,module,exports){(function(global){var _self=typeof window!=="undefined"?window:typeof WorkerGlobalScope!=="undefined"&&self instanceof WorkerGlobalScope?self:{};var Prism=function(){var lang=/\blang(?:uage)?-(\w+)\b/i;var uniqueId=0;var _=_self.Prism={manual:_self.Prism&&_self.Prism.manual,disableWorkerMessageHandler:_self.Prism&&_self.Prism.disableWorkerMessageHandler,util:{encode:function(tokens){if(tokens instanceof Token){return new Token(tokens.type,_.util.encode(tokens.content),tokens.alias)}else if(_.util.type(tokens)==="Array"){return tokens.map(_.util.encode)}else{return tokens.replace(/&/g,"&").replace(/text.length){return}if(str instanceof Token){continue}pattern.lastIndex=0;var match=pattern.exec(str),delNum=1;if(!match&&greedy&&i!=strarr.length-1){pattern.lastIndex=pos;match=pattern.exec(text);if(!match){break}var from=match.index+(lookbehind?match[1].length:0),to=match.index+match[0].length,k=i,p=pos;for(var len=strarr.length;k=p){++i;pos=p}}if(strarr[i]instanceof Token||strarr[k-1].greedy){continue}delNum=k-i;str=text.slice(pos,p);match.index-=pos}if(!match){if(oneshot){break}continue}if(lookbehind){lookbehindLength=match[1].length}var from=match.index+lookbehindLength,match=match[0].slice(lookbehindLength),to=from+match.length,before=str.slice(0,from),after=str.slice(to);var args=[i,delNum];if(before){++i;pos+=before.length;args.push(before)}var wrapped=new Token(token,inside?_.tokenize(match,inside):match,alias,match,greedy);args.push(wrapped);if(after){args.push(after)}Array.prototype.splice.apply(strarr,args);if(delNum!=1)_.matchGrammar(text,strarr,grammar,i,pos,true,token);if(oneshot)break}}}},tokenize:function(text,grammar,language){var strarr=[text];var rest=grammar.rest;if(rest){for(var token in rest){grammar[token]=rest[token]}delete grammar.rest}_.matchGrammar(text,strarr,grammar,0,0,false);return strarr},hooks:{all:{},add:function(name,callback){var hooks=_.hooks.all;hooks[name]=hooks[name]||[];hooks[name].push(callback)},run:function(name,env){var callbacks=_.hooks.all[name];if(!callbacks||!callbacks.length){return}for(var i=0,callback;callback=callbacks[i++];){callback(env)}}}};var Token=_.Token=function(type,content,alias,matchedStr,greedy){this.type=type;this.content=content;this.alias=alias;this.length=(matchedStr||"").length|0;this.greedy=!!greedy};Token.stringify=function(o,language,parent){if(typeof o=="string"){return o}if(_.util.type(o)==="Array"){return o.map(function(element){return Token.stringify(element,language,o)}).join("")}var env={type:o.type,content:Token.stringify(o.content,language,parent),tag:"span",classes:["token",o.type],attributes:{},language:language,parent:parent};if(o.alias){var aliases=_.util.type(o.alias)==="Array"?o.alias:[o.alias];Array.prototype.push.apply(env.classes,aliases)}_.hooks.run("wrap",env);var attributes=Object.keys(env.attributes).map(function(name){return name+'="'+(env.attributes[name]||"").replace(/"/g,""")+'"'}).join(" ");return"<"+env.tag+' class="'+env.classes.join(" ")+'"'+(attributes?" "+attributes:"")+">"+env.content+""};if(!_self.document){if(!_self.addEventListener){return _self.Prism}if(!_.disableWorkerMessageHandler){_self.addEventListener("message",function(evt){var message=JSON.parse(evt.data),lang=message.language,code=message.code,immediateClose=message.immediateClose;_self.postMessage(_.highlight(code,_.languages[lang],lang));if(immediateClose){_self.close()}},false)}return _self.Prism}var script=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();if(script){_.filename=script.src;if(!_.manual&&!script.hasAttribute("data-manual")){if(document.readyState!=="loading"){if(window.requestAnimationFrame){window.requestAnimationFrame(_.highlightAll)}else{window.setTimeout(_.highlightAll,16)}}else{document.addEventListener("DOMContentLoaded",_.highlightAll)}}}return _self.Prism}();if(typeof module!=="undefined"&&module.exports){module.exports=Prism}if(typeof global!=="undefined"){global.Prism=Prism}Prism.languages.markup={comment://,prolog:/<\?[\s\S]+?\?>/,doctype://i,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+)/i,inside:{punctuation:[/^=/,{pattern:/(^|[^\\])["']/,lookbehind:true}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i};Prism.languages.markup["tag"].inside["attr-value"].inside["entity"]=Prism.languages.markup["entity"];Prism.hooks.add("wrap",function(env){if(env.type==="entity"){env.attributes["title"]=env.content.replace(/&/,"&")}});Prism.languages.xml=Prism.languages.markup;Prism.languages.html=Prism.languages.markup;Prism.languages.mathml=Prism.languages.markup;Prism.languages.svg=Prism.languages.markup;Prism.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(?:;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^{}\s][^{};]*?(?=\s*\{)/,string:{pattern:/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:true},property:/[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,important:/\B!important\b/i,function:/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:]/};Prism.languages.css["atrule"].inside.rest=Prism.util.clone(Prism.languages.css);if(Prism.languages.markup){Prism.languages.insertBefore("markup","tag",{style:{pattern:/()[\s\S]*?(?=<\/style>)/i,lookbehind:true,inside:Prism.languages.css,alias:"language-css",greedy:true}});Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag)}Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:true},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:true}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:true},"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i,lookbehind:true,inside:{punctuation:/[.\\]/}},keyword:/\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,boolean:/\b(?:true|false)\b/,function:/[a-z0-9_]+(?=\()/i,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/};Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|\d*\.?\d+(?:[Ee][+-]?\d+)?|NaN|Infinity)\b/,function:/[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*\()/i,operator:/-[-=]?|\+[+=]?|!=?=?|<>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/});Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^\/])\/(?!\/)(\[[^\]\r\n]+]|\\.|[^\/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:true,greedy:true},"function-variable":{pattern:/[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i,alias:"function"}});Prism.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\[\s\S]|[^\\`])*`/,greedy:true,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}});if(Prism.languages.markup){Prism.languages.insertBefore("markup","tag",{script:{pattern:/()[\s\S]*?(?=<\/script>)/i,lookbehind:true,inside:Prism.languages.javascript,alias:"language-javascript",greedy:true}})}Prism.languages.js=Prism.languages.javascript;(function(){if(typeof self==="undefined"||!self.Prism||!self.document||!document.querySelector){return}self.Prism.fileHighlight=function(){var Extensions={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"};Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(pre){var src=pre.getAttribute("data-src");var language,parent=pre;var lang=/\blang(?:uage)?-(?!\*)(\w+)\b/i;while(parent&&!lang.test(parent.className)){parent=parent.parentNode}if(parent){language=(pre.className.match(lang)||[,""])[1]}if(!language){var extension=(src.match(/\.(\w+)$/)||[,""])[1];language=Extensions[extension]||extension}var code=document.createElement("code");code.className="language-"+language;pre.textContent="";code.textContent="Loading…";pre.appendChild(code);var xhr=new XMLHttpRequest;xhr.open("GET",src,true);xhr.onreadystatechange=function(){if(xhr.readyState==4){if(xhr.status<400&&xhr.responseText){code.textContent=xhr.responseText;Prism.highlightElement(code)}else if(xhr.status>=400){code.textContent="✖ Error "+xhr.status+" while fetching file: "+xhr.statusText}else{code.textContent="✖ Error: File does not exist or is empty"}}};xhr.send(null)})};document.addEventListener("DOMContentLoaded",self.Prism.fileHighlight)})()}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}]},{},[1])(1)});