public class SemicolonResourceContentAnnotator extends ResourceContentAnnotator
If a JavaScript file follows another that doesn't end with a semicolon, when it's batched, it's possible for the semantics of the JavaScript to change. Consider the following:
// FILE ONE.js
console.log("Loading...")
// FILE TWO.js
(function () {})()
When batched, it's turned into:
console.log("Loading...")(function () {})()
(Notice that the result of `console.log` is being *executed* with `function () {}` passed in as an argument. This
means you'll get an exception like this:
TypeError: undefined is not a functionThis is a stateless implementation of the
ResourceContentAnnotator that will write a semicolon before and
after each resource.| Constructor and Description |
|---|
SemicolonResourceContentAnnotator() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterResourceInBatch(LinkedHashSet<String> requiredResources,
Resource resource,
OutputStream stream)
Called after the resource content is written in batch.
|
int |
beforeResourceInBatch(LinkedHashSet<String> requiredResources,
Resource resource,
OutputStream stream)
Called before the resource content is written in batch.
|
int |
hashCode()
Produce a hash for this instance.
|
afterAllResourcesInBatch, afterResource, beforeAllResourcesInBatch, beforeResourcepublic int beforeResourceInBatch(LinkedHashSet<String> requiredResources, Resource resource, OutputStream stream) throws IOException
ResourceContentAnnotatorbeforeResourceInBatch in class ResourceContentAnnotatorIOException - if there is a problem writing the annotation.public void afterResourceInBatch(LinkedHashSet<String> requiredResources, Resource resource, OutputStream stream) throws IOException
ResourceContentAnnotatorafterResourceInBatch in class ResourceContentAnnotatorIOException - if there is a problem writing the annotation.public int hashCode()
ResourceContentAnnotatorhashCode in class ResourceContentAnnotatorCopyright © 2017 Atlassian. All rights reserved.