<commit_before>{{>header}}

{{>nav this}}

	<div class="o-techdocs-main o-techdocs-content">

		<h1>Common contribution scenarios</h1>

		<p>A few scenarios come up time and again on our issue tracker. If you want to contribute, and one of the scenarios below describes what you want to change, follow the steps to achieve a painless and rapidly merged pull request!</p>


		<h3 id='adding-browsers'>A particular polyfill is being served to the wrong browsers / not enough browsers</h3>

		<p>Commonly, people want to take a polyfill we already have and get us to serve it to a browser that we currently don't target with that polyfill. Often this is because it's a less common browser and we just haven't tested the polyfill in that browser, so adding the extra browser as a target does make sense.</p>

		<ol>
			<li>Update the relevant polyfill's <code>config.json</code> file to add, remove or change the value of the browser version constraint</li>
			<li>Check that your change is in line with the documentation on writing <a href='/v{{apiversion}}/docs/contributing/authoring-polyfills#configuration'>configuration JSON</a></li>
			<li>Open a pull request with the following information</li>
			<li>Check reliable sources of browser support information, e.g. MDN, caniuse and Kangax.  Tell us what these sources say about the browser/polyfill combo that you want to add or remove, and link to the relevant pages from your PR.</li>
			<li>Explain how you have tested support (or lack of) in the browser concerned.  Ideally, include a screenshot of the relevant browser running our test suite for that feature.</li>
			<li>State your agreement to our contribution terms.</li>
		</ol>


		<h3 id='new-browser'>The service is incorrectly identifying a browser</h3>

		<p>Although there are only five significant rendering engines (blink, presto, trident, gecko and webkit), there are lots of distinct browsers and user agents. We don't currently support anywhere near all of them, but are happy to add support on demand.</p>

		<ol>
			<li><a href='http://www.whatsmyua.com/'>Find out</a> the <code>User-Agent</code> header value sent by the browser</li>
			<li>Load <code>https://cdn.polyfill.io/v2/polyfill.js?ua={UAHEADER}</code> and take note of the detected, normalised browser name (e.g. 'chrome/40') that is displayed in the comment at the top of the output</li>
			<li>Work out which of our existing families the browser matches, e.g. Firefox for iOS is most usefully seen as an alias of Safari for iOS.</li>
			<li>Make the apppropriate change:
			<ul>
				<li>If the browser is misrecognised as another browser that we support (e.g. niche Acme browser is recognised as 'chrome' but it's actually gecko based), the family is right but the version number is wrong, or it's coming up as 'unknown', this is probably a problem with the node useragent module. Check our <code>UA.js</code> module to ensure we don't have any crazy aliasing rules that are misbehaving, then raise your issue in the useragent repo, not here.</li>
				<li>If the family is an unsupported browser but a supported one would suffice and the version is correct, make the niche browser an alias for the supported one in the <code>UA.js</code> module.</li>
				<li>If the family is an unsupported browser and we have no existing supported family that would be comparable, consider creating a new supported family, which will require updates to <code>UA.js</code>, all relevant polyfill <code>config.json</code> files, and the documentation in <code>/docs</code>.  This adds a significant maintenance burden, and we will strongly prefer to make an imperfect alias rather than create a new supported family.</li>
			</ul>
			</li>
			<li>Open a PR with the following info: the raw UA string and as many variations as you've found, the normalised UA name that we currently produce for that raw UA, and a description of your rationale for the change you've made.</li>
			<li>State your agreement to our contribution terms.</li>
		</ol>

		<h3 id='new-polyfill'>You want to add support for a feature not currently in the service</h3>

		<p>You want to add a new polyfill?  That's brilliant.  Here's how you do that:</p>

		<ol>
			<li>Search for existing polyfills online - has someone already created one that you can use?</li>
			<li>Make sure that the polyfill correctly implements the aspects of the spec that it seeks to emulate</li>
			<li>Follow our guidelines for the best practice <a href='/v{{apiversion}}/docs/contributing/authoring-polyfills#authoring-guidelines'>architecture</a> of original, or 3rd party polyfills</li>
			<li>Save your polyfill code in a file called <code>polyfill.js</code> in a new subdirectory of the <code>/polyfills</code> directory, named for the JavaScript global that accesses the feature (or if the feature has no JavaScript API, use a descriptive name prefixed with a tilde, e.g. <code>~html5-elements</code>)</li>
			<li>Add a well defined config.json, following the guidelines for <a href='/v{{apiversion}}/docs/contributing/authoring-polyfills#configuration'>configuring polyfills</a>.</li>
			<li>Add a feature detect in a <code>detect.js</code> file if it's possible to detect the feature via a JavaScript expression.</li>
			<li>Write a reasonably comprehensive set of tests in a <code>tests.js</code> file, and check that they pass in all the browsers you have targeted.</li>
			<li>Run <code>grunt ci</code> to check that library still passes our continuous integration tests. For help connecting to a Sauce Labs account, see <a href='/v{{apiversion}}/docs/contributing/testing#runing-tests-sauce'>running tests on Sauce Labs</a>.</li>
			<li>Open a pull request, including links to evidence of agreement on browser support from reliable sources, ie MDN, caniuse and/or Kangax, a screenshot of the test results in a targeted browser, and the results of your CI test run.</li>
			<li>State your agreement to our contribution terms.</li>
		</ol>

		<h3 id='update-polyfill'>A polyfill needs to be updated from a third party source</h3>

		<p>We have an out of date version of a 3rd party polyfill in our repo, and you want to update it to the latest version.</p>

		<ol>
			<li>Bump the version of the package inside <code>package.json<code></li>
			<li>Is there a <code>tests.js</code> file in the polyfill's directory?
			<ol>
				<li>Yes: If the new version has added support for more of the native feature, add tests to cover it in the <code>tests.js</code> file.</li>
			</ol>
			</li>
			<li>Run <code>grunt updatelibrary<code> to install the new version of the library</li>
			<li>Run <code>grunt ci</code> to check that library still passes our continuous integration tests. For help connecting to a Sauce Labs account, see <a href='/v{{apiversion}}/docs/contributing/testing#runing-tests-sauce'>running tests on Sauce Labs</a>.</li>
			<li>Open a pull request, stating the version of the polyfill you are changing, noting any functional changes that the new version brings</li>
			<li>State your agreement to our contribution terms.</li>
		</ol>

		<h3 id='improve-polyfill'>A polyfill is not correctly/completely emulating the missing feature</h3>

		<p>You want to improve a polyfill to make it better emulate the relevant native feature.</p>

		<ol>
			<li>If the polyfill's config.json has a <code>repo</code> property, then it is a third party dependency. Raise your change with the upstream project and then update it in the polyfill service (see above).  Otherwise...</li>
			<li>Make your change to the polyfill.js file</li>
			<li>Add tests for your new functionality in tests.js (these should fail without your changes to polyfill.js, and pass afterwards)</li>
			<li>Run <code>grunt ci</code> to check that library still passes our continuous integration tests. For help connecting to a Sauce Labs account, see <a href='/v{{apiversion}}/docs/contributing/testing#runing-tests-sauce'>running tests on Sauce Labs</a>.</li>
			<li>Open a pull request, with a description of the deficiency of the polyfill and how you've fixed it. Ideally link to spec documentation that specifies the behaviour that you are correcting.  Finally, tell us how this aspect of the feature is treated in native implementations (so, for example if you can correct a polyfill to acheive better conformance to the spec but this then deviates from how all browsers have consistently implemented it natively, we'll probably prefer to respect the implementation rather than the spec)</li>
			<li>State your agreement to our contribution terms.</li>
		</ol>
	</div>

{{>footer}}<commit_msg>Update docs with better walkthroughs (#801)<commit_after>{{>header}}

{{>nav this}}

	<div class="o-techdocs-main o-techdocs-content">

		<h1>Common contribution scenarios</h1>

		<p>A few scenarios come up time and again on our issue tracker. If you want to contribute, and one of the scenarios below describes what you want to change, follow the steps to achieve a painless and rapidly merged pull request!</p>


		<h3 id='adding-browsers'>A particular polyfill is being served to the wrong browsers / not enough browsers</h3>

		<p>Commonly, people want to take a polyfill we already have and get us to serve it to a browser that we currently don't target with that polyfill. Often this is because it's a less common browser and we just haven't tested the polyfill in that browser, so adding the extra browser as a target does make sense.</p>

		<ol>
			<li>Update the relevant polyfill's <code>config.json</code> file (<a href='https://github.com/Financial-Times/polyfill-service/blob/master/polyfills/Intl/config.json'>here's an example</a>) to add, remove or change the value of the browser version constraint</li>
			<li>Check that your change is in line with the documentation on writing <a href='/v{{apiversion}}/docs/contributing/authoring-polyfills#configuration'>configuration JSON</a></li>
			<li>Open a pull request with the following information</li>
			<li>Check reliable sources of browser support information, e.g. MDN, caniuse and Kangax.  Tell us what these sources say about the browser/polyfill combo that you want to add or remove, and link to the relevant pages from your PR.</li>
			<li>Explain how you have tested support (or lack of) in the browser concerned.  Ideally, include a screenshot of the relevant browser running our test suite for that feature.</li>
			<li>State your agreement to our <a href='https://polyfill.io/v2/docs/contributing#contribution-terms'>contribution terms</a>.</li>
		</ol>


		<h3 id='new-browser'>The service is incorrectly identifying a browser</h3>

		<p>Although there are only five significant rendering engines (blink, presto, trident, gecko and webkit), there are lots of distinct browsers and user agents. We don't currently support anywhere near all of them, but are happy to add support on demand.</p>

		<ol>
			<li><a href='http://www.whatsmyua.com/'>Find out</a> the <code>User-Agent</code> header value sent by the browser</li>
			<li>Load <code>https://cdn.polyfill.io/v2/polyfill.js?ua={UAHEADER}</code> and take note of the detected, normalised browser name (e.g. 'chrome/40') that is displayed in the comment at the top of the output</li>
			<li>Work out which of our existing families the browser matches, e.g. Firefox for iOS is most usefully seen as an alias of Safari for iOS.</li>
			<li>Make the apppropriate change:
			<ul>
				<li>If the browser is misrecognised as another browser that we support (e.g. niche Acme browser is recognised as 'chrome' but it's actually gecko based), the family is right but the version number is wrong, or it's coming up as 'unknown', this is probably a problem with the node useragent module. Check our <code>UA.js</code> module to ensure we don't have any crazy aliasing rules that are misbehaving, then raise your issue in the <a href='https://github.com/ua-parser/uap-core'>ua-parser/uap-core repo</a>, not here (here's <a href='https://github.com/ua-parser/uap-core/pull/155'>an example of a really good PR</a>).</li>
				<li>If the family is an unsupported browser but a supported one would suffice and the version is correct, make the niche browser an alias for the supported one in the <a href='https://github.com/Financial-Times/polyfill-service/blob/master/lib/UA.js'><code>UA.js</code></a> module.</li>
				<li>If the family is an unsupported browser and we have no existing supported family that would be comparable, consider creating a new supported family, which will require updates to <code>UA.js</code>, all relevant polyfill <code>config.json</code> files, and the documentation in <code>/docs</code>.  This adds a significant maintenance burden, and we will strongly prefer to make an imperfect alias rather than create a new supported family.</li>
			</ul>
			</li>
			<li>Open a PR with the following info: the raw UA string and as many variations as you've found, the normalised UA name that we currently produce for that raw UA, and a description of your rationale for the change you've made.</li>
			<li>State your agreement to our <a href='https://polyfill.io/v2/docs/contributing#contribution-terms'>contribution terms</a>.</li>
		</ol>

		<h3 id='new-polyfill'>You want to add support for a feature not currently in the service</h3>

		<p>You want to add a new polyfill?  That's brilliant.  Here's how you do that:</p>

		<ol>
			<li>Search for existing polyfills online - has someone already created one that you can use?</li>
			<li>Make sure that the polyfill correctly implements the aspects of the spec that it seeks to emulate</li>
			<li>If you want to use a third party polyfill available on npm:<ol>
				<li>Write a well defined config.json, following the guidelines for <a href='/v{{apiversion}}/docs/contributing/authoring-polyfills#configuration'>configuring polyfills</a>, and including an <code>install</code> section refering to the source module and path.</li>
				<li>Add the npm module to our package.json file and regenerate the shrinkwrap.</li>
			</ol></li>
			<li>If you want to write an original polyfill:<ol>
				<li>Follow our guidelines for the best practice <a href='/v{{apiversion}}/docs/contributing/authoring-polyfills#authoring-guidelines'>architecture</a> of original polyfills</li>
				<li>Save your polyfill code in a file called <code>polyfill.js</code> in a new subdirectory of the <code>/polyfills</code> directory, named for the JavaScript global that accesses the feature (or if the feature has no JavaScript API, use a descriptive name prefixed with a tilde, e.g. <code>~html5-elements</code>)</li>
				<li>Add a well defined config.json, following the guidelines for <a href='/v{{apiversion}}/docs/contributing/authoring-polyfills#configuration'>configuring polyfills</a>.</li>
				<li>Write a reasonably comprehensive set of tests in a <code>tests.js</code> file, and check that they pass in all the browsers you have targeted.</li>
			</ol></li>
			<li>Add a feature detect in a <code>detect.js</code> file if it's possible to detect the feature via a JavaScript expression.</li>
			<li>Run <code>grunt ci</code> to check that library still passes our continuous integration tests. For help connecting to a Sauce Labs account, see <a href='/v{{apiversion}}/docs/contributing/testing#runing-tests-sauce'>running tests on Sauce Labs</a>.</li>
			<li>Open a pull request, including links to evidence of browser support from reliable sources, ie <a href='https://developer.mozilla.org/en-US/'>MDN</a>, <a href='http://caniuse.com/'>caniuse</a> and/or <a href='https://kangax.github.io/compat-table/es6/'>Kangax</a>, and a screenshot of the test results in a targeted browser.</li>
			<li>State your agreement to our <a href='https://polyfill.io/v2/docs/contributing#contribution-terms'>contribution terms</a>.</li>
		</ol>

		<h3 id='update-polyfill'>A polyfill needs to be updated from a third party source</h3>

		<p>We have an out of date version of a 3rd party polyfill in our repo, and you want to update it to the latest version.</p>

		<ol>
			<li>Bump the version of the package inside <code>package.json<code> and re-run <code>npm shrinkwrap</code> if required.</li>
			<li>If there is a <code>tests.js</code> file in the polyfill's directory, and the new version has added support for more of the native feature, add tests to cover it in the <code>tests.js</code> file.</li>
			<li>Run <code>grunt updatelibrary<code> to install the new version of the library</li>
			<li>Run <code>grunt ci</code> to check that library still passes our continuous integration tests. For help connecting to a Sauce Labs account, see <a href='/v{{apiversion}}/docs/contributing/testing#runing-tests-sauce'>running tests on Sauce Labs</a>.</li>
			<li>Open a pull request, stating the version of the polyfill you are changing, noting any functional changes that the new version brings</li>
			<li>State your agreement to our <a href='https://polyfill.io/v2/docs/contributing#contribution-terms'>contribution terms</a>.</li>
		</ol>

		<h3 id='improve-polyfill'>A polyfill is not correctly/completely emulating the missing feature</h3>

		<p>You want to improve a polyfill to make it better emulate the relevant native feature.</p>

		<ol>
			<li>If the polyfill's config.json has a <code>repo</code> or <code>install</code> property, then it is a third party dependency. Raise your change with the upstream project and then update it in the polyfill service (see above).  Otherwise...</li>
			<li>Make your change to the polyfill.js file</li>
			<li>Add tests for your new functionality in tests.js (these should fail without your changes to polyfill.js, and pass afterwards)</li>
			<li>Run <code>grunt ci</code> to check that library still passes our continuous integration tests. For help connecting to a Sauce Labs account, see <a href='/v{{apiversion}}/docs/contributing/testing#runing-tests-sauce'>running tests on Sauce Labs</a>.</li>
			<li>Open a pull request, with a description of the deficiency of the polyfill and how you've fixed it. Ideally link to spec documentation that specifies the behaviour that you are correcting.  Finally, tell us how this aspect of the feature is treated in native implementations (so, for example if you can correct a polyfill to acheive better conformance to the spec but this then deviates from how all browsers have consistently implemented it natively, we'll probably prefer to respect the implementation rather than the spec)</li>
			<li>State your agreement to our <a href='https://polyfill.io/v2/docs/contributing#contribution-terms'>contribution terms</a>.</li>
		</ol>
	</div>

{{>footer}}
{'fraction_non_alphanumeric': 0.09616934400687692, 'fraction_numerical': 0.002525116853811852, 'mean_word_length': 4.4141942990110525, 'pattern_counts': {'":': 0, '<': 387, '<?xml version=': 0, '>': 393, 'https://': 13, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4214650', 'n_tokens_mistral': 5596, 'n_tokens_neox': 5112, 'n_words': 2438}