Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: syntax errors in JS example sections (v3) #18307

Merged
merged 11 commits into from
Jul 16, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ const stream = new WritableStream({

}
}, {
highWaterMark,
size()
highWaterMark: 3,
size: () => 1
Comment on lines -52 to +53
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

});
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ within the button elements style attribute.
const buttonEl = document.querySelector('.example');

// find what's in the style attribute with attributeStyleMap and has()
const hasPadTop = buttonEl.attributeStyleMap.has('padding-top);
const hasPadTop = buttonEl.attributeStyleMap.has('padding-top');

console.log(hasPadTop); // logs true if padding-top is present in style attribute
```
Expand Down
4 changes: 2 additions & 2 deletions files/en-us/web/api/svgaelement/target/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ Sample values can be found [here](https://www.w3.org/TR/2011/REC-SVG11-20110816/
The code is taken from the ["SVGAElement example code"](/en-US/docs/Web/API/SVGAElement#example)

```js
...
// ...
var linkRef = document.querySelector('a');
linkRef.target ='_blank';
...
// ...
```

## Specifications
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/svganimatedstring/animval/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ AnimVal attribute or animVal property contains the same value as the {{domxref("
## Syntax

```js
var = object.animVal
var currentValue = object.animVal
```

## Specifications
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/svgrect/the__x__property/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ The [x](https://svgwg.org/svg2-draft/geometry.html#XProperty) property describes

A \<coordinate> is a length in the user coordinate system that is the given distance from the origin of the user coordinate system along the relevant axis (the x-axis for X coordinates, the y-axis for Y coordinates). Its syntax is the same as that for [\<length>](https://www.w3.org/TR/SVG11/types.html#DataTypeLength)

```js
```go
Copy link
Contributor Author

@lionralfs lionralfs Jul 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Rect draws a rectangle with upper left-hand corner at x,y, with width w, and height h, with optional style
// Standard Reference: http://www.w3.org/TR/SVG11/shapes.html#RectElement
func (svg *SVG) Rect(x float64, y float64, w float64, h float64, s ...string) {
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/texttrackcue/exit_event/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ In the following example, `cue1` prints to the console when it stops being displ
```js
cue1.addEventListener('enter', event => {
console.log('Cue 1 has left the building.');
}
});
```

## Specifications
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The application uses {{HTMLElement("div")}} elements to represent four touch are
const logEvents = false;

// Touch Point cache
cosnt tpCache = new Array();
const tpCache = new Array();
```

### Register event handlers
Expand Down Expand Up @@ -247,14 +247,12 @@ function log(name, ev, printTargetIds) {
let s = name + ": touches = " + ev.touches.length +
" ; targetTouches = " + ev.targetTouches.length +
" ; changedTouches = " + ev.changedTouches.length;
o.innerHTML += s + "
";
o.innerHTML += s + "<br>";

if (printTargetIds) {
s = "";
for (var i=0; i < ev.targetTouches.length; i++) {
s += "... id = " + ev.targetTouches[i].identifier + "
";
s += "... id = " + ev.targetTouches[i].identifier + "<br>";
}
o.innerHTML += s;
}
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/touchlist/item/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ target.addEventListener('touchstart', function(ev) {
// If this touchstart event started on element target,
// set touch to the first item in the targetTouches list;
// otherwise set touch to the first item in the touches list
const touch;
let touch;

if (ev.targetTouches.length >= 1)
touch = ev.targetTouches.item(0);
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/trackevent/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ videoElem.textTracks.addEventListener("addtrack", handleTrackEvent, false);
videoElem.textTracks.addEventListener("removetrack", handleTrackEvent, false);

function handleTrackEvent(event) {
const trackKind;
let trackKind;

if (event.target instanceof VideoTrackList) {
trackKind = "video";
Expand Down
4 changes: 3 additions & 1 deletion files/en-us/web/api/treewalker/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ _This interface doesn't inherit any method._
```js
let walker = document.createTreeWalker(document.body, NodeFilter.SHOW_ALL);
let node = walker.firstChild(); // nodeName: "#text"
// But if we do:
```
But if we do:
```js
let walker = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT);
let node = walker.firstChild(); // nodeName: "DIV"
```
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/trustedscripturl/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The constant `sanitized` is an object created via a Trusted Types policy.

```js
const sanitized = scriptPolicy.createScriptURL("https://example.com/my-script.js");
console.log(sanitized;) /* a TrustedScriptURL object */
console.log(sanitize); /* a TrustedScriptURL object */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be sanitized?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, you're absolutely right. One backspace too much 😅

```

## Specifications
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/vrdisplay/submitframe/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function drawVRScene() {
// for passing into the uniformMatrix4fv methods below

const projectionMatrixLocation = gl.getUniformLocation(shaderProgram, "projMatrix");
cosnt viewMatrixLocation = gl.getUniformLocation(shaderProgram, "viewMatrix");
const viewMatrixLocation = gl.getUniformLocation(shaderProgram, "viewMatrix");

// WebVR: Render the left eye's view to the left half of the canvas
gl.viewport(0, 0, canvas.width * 0.5, canvas.height);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ osc.type = osc.SAWTOOTH; // sawtooth waveform
osc.type = osc.TRIANGLE; // triangle waveform
osc.setWaveTable(table);
const isCustom = (osc.type == osc.CUSTOM); // isCustom will be true
```

```js
// New standard AudioContext code:
const osc = context.createOscillator();
osc.type = "sine"; // sine waveform
Expand All @@ -179,7 +181,9 @@ filter.type = filter.HIGHSHELF; // highshelf filter
filter.type = filter.PEAKING; // peaking filter
filter.type = filter.NOTCH; // notch filter
filter.type = filter.ALLPASS; // allpass filter
```

```js
// New standard AudioContext code:
const filter = context.createBiquadFilter();
filter.type = "lowpass"; // lowpass filter
Expand All @@ -201,7 +205,9 @@ filter.type = "allpass"; // allpass filter
const panner = context.createPanner();
panner.panningModel = panner.EQUALPOWER; // equalpower panning
panner.panningModel = panner.HRTF; // HRTF panning
```

```js
// New standard AudioContext code:
const panner = context.createPanner();
panner.panningModel = "equalpower"; // equalpower panning
Expand All @@ -218,7 +224,9 @@ const panner = context.createPanner();
panner.distanceModel = panner.LINEAR_DISTANCE; // linear distance model
panner.distanceModel = panner.INVERSE_DISTANCE; // inverse distance model
panner.distanceModel = panner.EXPONENTIAL_DISTANCE; // exponential distance model
```

```js
// Mew standard AudioContext code:
const panner = context.createPanner();
panner.distanceModel = "linear"; // linear distance model
Expand All @@ -241,7 +249,9 @@ src.buffer = someBuffer;
src.gain.value = 0.5;
src.connect(context.destination);
src.noteOn(0);
```

```js
// New standard AudioContext code:
const src = context.createBufferSource();
src.buffer = someBuffer;
Expand All @@ -263,7 +273,9 @@ src.buffer = someBuffer;
src.buffer.gain = 0.5;
src.connect(context.destination);
src.noteOn(0);
```

```js
// New standard AudioContext code:
const src = context.createBufferSource();
src.buffer = someBuffer;
Expand Down Expand Up @@ -306,7 +318,9 @@ The `playbackState` attribute of {{domxref("AudioBufferSourceNode")}} and {{domx
const src = context.createBufferSource();
// Some time later...
const isFinished = (src.playbackState == src.FINISHED_STATE);
```

```js
// New AudioContext code:
const src = context.createBufferSource();
function endedHandler(event) {
Expand Down Expand Up @@ -357,7 +371,7 @@ could be rewritten like that:
return sources.length;
}
const src0 = context.createBufferSource();
const src0 = context.createBufferSource();
const src1 = context.createBufferSource();
// Set buffers and other parameters...
startSource(src0, 0);
startSource(src1, 0);
Expand All @@ -374,7 +388,9 @@ The {{domxref("WaveTable")}} interface has been renamed to {{domxref("PeriodicWa
const osc = context.createOscillator();
const table = context.createWaveTable(realArray, imaginaryArray);
osc.setWaveTable(table);
```

```js
// New standard AudioContext code:
const osc = context.createOscillator();
const table = context.createPeriodicWave(realArray, imaginaryArray);
Expand Down