Closed Bug 598618 Opened 15 years ago Closed 15 years ago

addColorStop("1.0","rgba( 0, 0, 0, 0"); is an error, its not caught

Categories

(Core :: Graphics: Canvas2D, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: gary_johnson_53, Unassigned)

Details

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:2.0b6) Gecko/20100101 Firefox/4.0b6 Build Identifier: Mozilla/5.0 (Windows NT 5.1; rv:2.0b6) Gecko/20100101 Firefox/4.0b6 This works, gradient.addColorStop("1.0","rgba( 0, 0, 0, 0"); it should not gradient.addColorStop("1.0","rgba( 0, 0, 0, 0)"); function drawRG1() { if(!myDoCanvas) return; //width="640" height="442" if(!ctx) return; // createRadialGradient(x0, y0, fRadius0, x1, y1, fRadius1) gradient = ctx.createRadialGradient(75,75,0,75,75,75); ctx.fillStyle = getColors1(gradient); ctx.fillRect(0,0,640,442); } function getColors1(gradient) { gradient.addColorStop("0","purple"); gradient.addColorStop(".50","black"); gradient.addColorStop(".70","rgba(158, 81, 65, .41)"); gradient.addColorStop(".85","rgba(240, 139, 76, .65)"); gradient.addColorStop("1.0","rgba( 0, 0, 0, 0"); return(gradient); } Reproducible: Always Steps to Reproduce: 1. load the sample 2. see it work 3. check error console, no error Actual Results: it works Expected Results: it should show an error
Attached file TestCase 598618
See The addColorStop(offset, color) method on the CanvasGradient interface adds a new stop to a gradient. If the offset is less than 0, greater than 1, infinite, or NaN, then an INDEX_SIZE_ERR exception must be raised. If the color cannot be parsed as a CSS color, then a SYNTAX_ERR exception must be raised. This code var mycanvas = (document.getElementById("c1"); // needs )); at the end throws Error: missing ) in parenthetical See If the value is a string but is not a valid color, or is neither a string, a CanvasGradient, nor a CanvasPattern, then it must be ignored, and the attribute must retain its previous value. ?
Yep. Missing closing parentheses do not cause things to not be parsed as CSS; they're inferred by EOF. Simple testcase: data:text/html,<span style="color: rgb(0, 255, 0">Lime</span> Invalid as far as I can see, but I'll raise the issue in whatwg.
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → INVALID
if this is not going to throw an error gradient.addColorStop("1.0","rgba(0,0,0,0"); and this does ctx.fillStyle=""rgba(84,125,83,1)"; Error: missing ; before statement Source Code: and web developers see it in a javascript block, but in the first case its really a CSS token with an implied EOL, so that explains it. In the second case, I am guessing its malformed Javascript, so that explains why it gets an error, I vote that if this kind of coding is in a javascript block, that the rules of well formed javascript take precedence
> In the second case, I am guessing its malformed Javascript Correct. In fact it doesn't even parse as JavaScript, so never _runs_. > the rules of well formed javascript take precedence More precisely, since it never even runs what's going on with CSS, DOM, etc simply doesn't matter.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: